more python 3 compatibility

This commit is contained in:
Axel Kohlmeyer
2022-02-23 12:30:03 -05:00
parent 5594868ef2
commit 2d7375798f
8 changed files with 69 additions and 67 deletions

View File

@ -6,6 +6,8 @@
# certain rights in this software. This software is distributed under
# the GNU General Public License.
from __future__ import print_function
# xyz tool
oneline = "Convert LAMMPS snapshots to XYZ format"
@ -56,18 +58,18 @@ class xyz:
if flag == -1: break
time,box,atoms,bonds,tris,lines = self.data.viz(which)
print >>f,len(atoms)
print >>f,"Atoms"
print(len(atoms), file=f)
print("Atoms", file=f)
for atom in atoms:
itype = int(atom[1])
print >>f,itype,atom[2],atom[3],atom[4]
print(itype,atom[2],atom[3],atom[4], file=f)
print time,
print(time)
sys.stdout.flush()
n += 1
f.close()
print "\nwrote %d snapshots to %s in XYZ format" % (n,file)
print("\nwrote %d snapshots to %s in XYZ format" % (n,file))
# --------------------------------------------------------------------
@ -91,17 +93,17 @@ class xyz:
file = root + str(n)
file += ".xyz"
f = open(file,"w")
print >>f,len(atoms)
print >>f,"Atoms"
print(len(atoms), file=f)
print("Atoms", file=f)
for atom in atoms:
itype = int(atom[1])
print >>f,itype,atom[2],atom[3],atom[4]
print time,
print(itype,atom[2],atom[3],atom[4], file=f)
print(time)
sys.stdout.flush()
f.close()
n += 1
print "\nwrote %s snapshots in XYZ format" % n
print("\nwrote %s snapshots in XYZ format" % n)
# --------------------------------------------------------------------
@ -113,9 +115,9 @@ class xyz:
which = self.data.findtime(time)
time,box,atoms,bonds,tris,lines = self.data.viz(which)
f = open(file,"w")
print >>f,len(atoms)
print >>f,"Atoms"
print(len(atoms), file=f)
print("Atoms", file=f)
for atom in atoms:
itype = int(atom[1])
print >>f,itype,atom[2],atom[3],atom[4]
print(itype,atom[2],atom[3],atom[4], file=f)
f.close()