From: Stuart Prescott <stuart@debian.org>
Date: Sun, 9 Feb 2020 21:09:09 +1100
Subject: Port to Python 3

---
 doc/examples/Makefile.am                  |  4 +--
 doc/examples/Makefile.in                  |  4 +--
 doc/examples/atomisation.sh               |  2 +-
 doc/examples/boussinesq.sh                |  2 +-
 doc/examples/bubble.sh                    |  2 +-
 doc/examples/column.sh                    |  2 +-
 doc/examples/cyclone.sh                   |  2 +-
 doc/examples/cylinder.sh                  |  2 +-
 doc/examples/dam.sh                       |  2 +-
 doc/examples/depend.py                    | 26 +++++++++++---------
 doc/examples/forcedturbulence.sh          |  2 +-
 doc/examples/garden.sh                    |  2 +-
 doc/examples/gfs2doc.in                   | 20 +++++++--------
 doc/examples/gfs2tex                      |  2 +-
 doc/examples/gfs2tex.py                   |  2 +-
 doc/examples/hump.sh                      |  2 +-
 doc/examples/logo.sh                      |  2 +-
 doc/examples/monai.sh                     |  2 +-
 doc/examples/plateau.sh                   |  2 +-
 doc/examples/rt.sh                        |  2 +-
 doc/examples/ship.sh                      |  2 +-
 doc/examples/shock.sh                     |  2 +-
 doc/examples/starting.sh                  |  2 +-
 doc/examples/tangaroa.sh                  |  2 +-
 doc/examples/test.py                      | 12 ++++-----
 doc/examples/tides.sh                     |  2 +-
 doc/examples/tsunami.sh                   |  2 +-
 doc/examples/viscmix.sh                   |  2 +-
 doc/examples/wingtip.sh                   |  2 +-
 test/Makefile.am                          |  4 +--
 test/Makefile.in                          |  4 +--
 test/advection.sh                         |  2 +-
 test/advection/advection.sh               |  2 +-
 test/annulus.sh                           |  2 +-
 test/annulus/annulus.sh                   |  2 +-
 test/axi.sh                               |  2 +-
 test/axi/axi.sh                           |  2 +-
 test/axi/viscous/viscous.sh               |  4 +--
 test/axiadvection.sh                      |  2 +-
 test/boundaries.sh                        |  2 +-
 test/boundaries/boundaries.sh             | 26 ++++++++++----------
 test/bump.sh                              |  2 +-
 test/bump/bump.sh                         | 14 +++++------
 test/capwave.sh                           |  2 +-
 test/capwave/capwave.sh                   |  2 +-
 test/channel.sh                           |  2 +-
 test/channel/channel.sh                   | 26 ++++++++++----------
 test/check.py                             |  2 +-
 test/circle.sh                            |  2 +-
 test/circle/circle.sh                     | 10 ++++----
 test/conservation.sh                      |  2 +-
 test/coriolis.sh                          |  2 +-
 test/coriolis/coriolis.sh                 |  2 +-
 test/cosine.sh                            |  2 +-
 test/cosine/cosine.sh                     | 10 ++++----
 test/couette.sh                           |  2 +-
 test/couette/couette.sh                   |  6 ++---
 test/cylinder.sh                          |  2 +-
 test/cylinder/cylinder.sh                 |  6 ++---
 test/debye.sh                             |  2 +-
 test/debye/debye.sh                       |  8 +++---
 test/depend.py                            | 41 ++++++++++++++++++-------------
 test/diffusion.sh                         |  2 +-
 test/dumbell.sh                           |  2 +-
 test/electro.sh                           |  2 +-
 test/electro/electro.sh                   |  8 +++---
 test/gaussian.sh                          |  2 +-
 test/gaussian/gaussian.sh                 |  6 ++---
 test/geo.sh                               |  2 +-
 test/geo/beta/beta.sh                     |  2 +-
 test/geo/geo.sh                           |  2 +-
 test/geo/river/geo.sh                     |  2 +-
 test/gfs2tex                              |  2 +-
 test/groundwater.sh                       |  2 +-
 test/groundwater/groundwater.sh           |  8 +++---
 test/harmonic.sh                          |  2 +-
 test/harmonic/harmonic.sh                 |  6 ++---
 test/height.sh                            |  2 +-
 test/hexagon.sh                           |  2 +-
 test/hexagon/hexagon.sh                   |  2 +-
 test/hydrostatic.sh                       |  2 +-
 test/injectionaxi.sh                      |  2 +-
 test/kinetic.sh                           |  2 +-
 test/lake.sh                              |  2 +-
 test/lake/river/river.sh                  |  4 +--
 test/lake/stratified/stratified.sh        |  4 +--
 test/lid.sh                               |  2 +-
 test/lid/explicit/lid.sh                  |  6 ++---
 test/lid/lid.sh                           |  6 ++---
 test/lonlat.sh                            |  2 +-
 test/merging.sh                           |  2 +-
 test/merging/merging.sh                   | 22 ++++++++---------
 test/nonlinear.sh                         |  2 +-
 test/nonlinear/nonlinear.sh               |  8 +++---
 test/nz.sh                                |  2 +-
 test/oscillation.sh                       |  2 +-
 test/oscillation/oscillation.sh           |  2 +-
 test/parabola.sh                          |  2 +-
 test/parabola/parabola.sh                 |  4 +--
 test/periodic.sh                          |  2 +-
 test/periodic/periodic.sh                 | 28 ++++++++++-----------
 test/planar.sh                            |  2 +-
 test/plate.sh                             |  2 +-
 test/plateau.sh                           |  2 +-
 test/poiseuille.sh                        |  2 +-
 test/poiseuille/poiseuille.sh             |  2 +-
 test/poiseuille/river/river.sh            |  2 +-
 test/poisson.sh                           |  2 +-
 test/poisson/poisson.sh                   | 10 ++++----
 test/reynolds.sh                          |  2 +-
 test/reynolds/reynolds.sh                 |  6 ++---
 test/reynolds/skew/skew.sh                |  2 +-
 test/reynolds/skewbox/skew.sh             |  6 ++---
 test/rossby.sh                            |  2 +-
 test/rossby/rossby.sh                     |  6 ++---
 test/rotate.sh                            |  2 +-
 test/sessile.sh                           |  2 +-
 test/sessile/sessile.sh                   |  4 +--
 test/shear.sh                             |  2 +-
 test/shear/concentration/concentration.sh |  2 +-
 test/shear/shear.sh                       |  2 +-
 test/shock.sh                             |  2 +-
 test/shock/layered/layered.sh             |  4 +--
 test/shock/shock.sh                       |  4 +--
 test/shore.sh                             |  2 +-
 test/shore/shore.sh                       |  8 +++---
 test/source.sh                            |  2 +-
 test/source/source.sh                     |  6 ++---
 test/spurious.sh                          |  2 +-
 test/spurious/spurious.sh                 |  2 +-
 test/still.sh                             |  2 +-
 test/strouhal.sh                          |  2 +-
 test/strouhal/strouhal.sh                 |  2 +-
 test/swirl.sh                             |  2 +-
 test/swirl/swirl.gfs                      |  6 ++---
 test/terrain.sh                           |  2 +-
 test/terrain/terrain.sh                   | 10 ++++----
 test/test.py                              | 18 +++++++-------
 test/wannier.sh                           |  2 +-
 test/wannier/bipolar/bipolar.sh           |  2 +-
 test/wannier/wannier.sh                   |  2 +-
 test/waves.sh                             |  2 +-
 test/waves/waves.sh                       |  2 +-
 143 files changed, 318 insertions(+), 309 deletions(-)

diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 32bc766..6e76223 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -68,7 +68,7 @@ DOC = examples
 BIBINPUTS = $(top_srcdir)/doc
 
 Makefile.deps: template.tex depend.py Makefile.am
-	python depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
+	python3 depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
 	echo "" >> Makefile.deps
 	echo -n "EXAMPLES = " >> Makefile.deps
 	echo `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` >> Makefile.deps
@@ -77,7 +77,7 @@ include Makefile.deps
 
 examples.tex: template.tex Makefile.deps gfs2tex gfs2tex.py
 	rm -r -f examples
-	python gfs2tex $(EXAMPLES)
+	python3 gfs2tex $(EXAMPLES)
 	sed -e "s/GFS_VERSION/`$(top_srcdir)/src/gerris2D -V 2>&1 | head -1 | cut -d' ' -f6-`/g" \
 	    -e 's/\\test{\(.*\)\/\(.*\)}/\\input{\1\/\2\/\2.tex}/g' \
 	    -e 's/\\test{\(.*\)}/\\input{\1\/\1.tex}/g' \
diff --git a/doc/examples/Makefile.in b/doc/examples/Makefile.in
index 18f09f3..8ac31c8 100644
--- a/doc/examples/Makefile.in
+++ b/doc/examples/Makefile.in
@@ -1240,7 +1240,7 @@ clean-generic:
 	$(RM) -r examples
 
 Makefile.deps: template.tex depend.py Makefile.am
-	python depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
+	python3 depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
 	echo "" >> Makefile.deps
 	echo -n "EXAMPLES = " >> Makefile.deps
 	echo `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` >> Makefile.deps
@@ -1409,7 +1409,7 @@ examples.tex: \
 
 examples.tex: template.tex Makefile.deps gfs2tex gfs2tex.py
 	rm -r -f examples
-	python gfs2tex $(EXAMPLES)
+	python3 gfs2tex $(EXAMPLES)
 	sed -e "s/GFS_VERSION/`$(top_srcdir)/src/gerris2D -V 2>&1 | head -1 | cut -d' ' -f6-`/g" \
 	    -e 's/\\test{\(.*\)\/\(.*\)}/\\input{\1\/\2\/\2.tex}/g' \
 	    -e 's/\\test{\(.*\)}/\\input{\1\/\1.tex}/g' \
diff --git a/doc/examples/atomisation.sh b/doc/examples/atomisation.sh
index b41135b..909ca3a 100755
--- a/doc/examples/atomisation.sh
+++ b/doc/examples/atomisation.sh
@@ -1 +1 @@
-python -u test.py atomisation
+python3 -u test.py atomisation
diff --git a/doc/examples/boussinesq.sh b/doc/examples/boussinesq.sh
index ad0a5d5..e91c9d3 100755
--- a/doc/examples/boussinesq.sh
+++ b/doc/examples/boussinesq.sh
@@ -1 +1 @@
-python -u test.py boussinesq
+python3 -u test.py boussinesq
diff --git a/doc/examples/bubble.sh b/doc/examples/bubble.sh
index e7871ff..239c587 100755
--- a/doc/examples/bubble.sh
+++ b/doc/examples/bubble.sh
@@ -1 +1 @@
-python -u test.py bubble
+python3 -u test.py bubble
diff --git a/doc/examples/column.sh b/doc/examples/column.sh
index 6a5eb50..1c131d4 100755
--- a/doc/examples/column.sh
+++ b/doc/examples/column.sh
@@ -1 +1 @@
-python -u test.py column
+python3 -u test.py column
diff --git a/doc/examples/cyclone.sh b/doc/examples/cyclone.sh
index 662f19a..00b1fae 100755
--- a/doc/examples/cyclone.sh
+++ b/doc/examples/cyclone.sh
@@ -1 +1 @@
-python -u test.py cyclone
+python3 -u test.py cyclone
diff --git a/doc/examples/cylinder.sh b/doc/examples/cylinder.sh
index 73135b6..c0390c4 100755
--- a/doc/examples/cylinder.sh
+++ b/doc/examples/cylinder.sh
@@ -1 +1 @@
-python -u test.py cylinder
+python3 -u test.py cylinder
diff --git a/doc/examples/dam.sh b/doc/examples/dam.sh
index 76bb320..5624bf8 100755
--- a/doc/examples/dam.sh
+++ b/doc/examples/dam.sh
@@ -1 +1 @@
-python -u test.py dam
+python3 -u test.py dam
diff --git a/doc/examples/depend.py b/doc/examples/depend.py
index 0e46ee9..fa41cf9 100644
--- a/doc/examples/depend.py
+++ b/doc/examples/depend.py
@@ -1,12 +1,12 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys
 import os
 import os.path
 import gfs2tex
 
-print "## File generated automatically by depend.py: do not modify by hand"
-print ""
+print("## File generated automatically by depend.py: do not modify by hand")
+print("")
 
 dists = ""
 depends = ""
@@ -15,9 +15,9 @@ tests = ""
 for start in sys.argv[1:]:
     tests += "\\\n\t" + start + ".sh"
     f = open(start + ".sh", "w")
-    f.write("python -u test.py " + start + "\n")
+    f.write("python3 -u test.py " + start + "\n")
     f.close()
-    os.chmod(start + ".sh",0755)
+    os.chmod(start + ".sh",0o755)
     for root, dirs, files in os.walk(start,topdown=True):
         if not ".xvpics" in root:
             example = gfs2tex.Example(root)
@@ -33,10 +33,12 @@ for start in sys.argv[1:]:
                 if f[-4:] == ".mpg" or f[-4:] == ".ogv" or f[-4:] == ".png" or f[-4:] == ".mp4":
                     docs += "\\\n\t" + example.path + "/" + f
 
-print "DOCS = " + docs + dists
-print ""
-print "TESTS = " + tests
-print ""
-print "EXTRA_DIST += $(TESTS)" + dists
-print ""
-print "examples.tex: " + depends
+print("DOCS = " + docs + dists)
+print("")
+print("TESTS = " + tests)
+print("")
+print("EXTRA_DIST += $(TESTS)" + dists)
+print("")
+print("TESTS = " + tests)
+print("")
+print("examples.tex: " + depends)
diff --git a/doc/examples/forcedturbulence.sh b/doc/examples/forcedturbulence.sh
index 38409f9..d1da5f1 100755
--- a/doc/examples/forcedturbulence.sh
+++ b/doc/examples/forcedturbulence.sh
@@ -1 +1 @@
-python -u test.py forcedturbulence
+python3 -u test.py forcedturbulence
diff --git a/doc/examples/garden.sh b/doc/examples/garden.sh
index fd9f1f5..67f9885 100755
--- a/doc/examples/garden.sh
+++ b/doc/examples/garden.sh
@@ -1 +1 @@
-python -u test.py garden
+python3 -u test.py garden
diff --git a/doc/examples/gfs2doc.in b/doc/examples/gfs2doc.in
index fd4f613..9f418b9 100644
--- a/doc/examples/gfs2doc.in
+++ b/doc/examples/gfs2doc.in
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys
 import os
@@ -10,7 +10,7 @@ sys.path.append("@prefix@/share/gerris")
 import gfs2tex
 
 if len(sys.argv) < 2:
-    print "usage: gfs2doc DIR1 DIR2..."
+    print("usage: gfs2doc DIR1 DIR2...")
     sys.exit(1)
 
 def myexit(s):
@@ -51,10 +51,10 @@ for d in sys.argv[1:]:
               "&& dvips -Ppdf -G0 " + example.name + ".dvi -o " + example.name + ".ps" +\
               "&& ps2pdf -sPAPERSIZE=a4 -dMaxSubsetPct=100 -dCompatibilityLevel=1.2 -dSubsetFonts=true -dEmbedAllFonts=true " + example.name + ".ps " + example.name + ".pdf" +\
               "&& mv " + example.name + ".pdf " + os.getcwd()):
-        print "\n\n**** Errors occured while generating file ****: " + example.name + ".pdf"
+        print("\n\n**** Errors occured while generating file ****: " + example.name + ".pdf")
         myexit(1)
         
-    print "\n\n**** Successfully generated file ****: " + example.name + ".pdf\n\n"
+    print("\n\n**** Successfully generated file ****: " + example.name + ".pdf\n\n")
     hname = wdname + "/" + example.name + "_html"
     os.mkdir(hname)
     os.symlink("../" + example.name, hname + "/" + example.name)
@@ -63,7 +63,7 @@ for d in sys.argv[1:]:
                  "&& cd " + wdname + \
 		 "&& hevea -fix -I @prefix@/share/gerris " + example.name + ".tex" + \
                  "&& sh @prefix@/share/gerris/kaltura.sh " + example.name):
-        print "\n\n**** Errors occured while generating directory ****: " + example.name + "_html"
+        print("\n\n**** Errors occured while generating directory ****: " + example.name + "_html")
         myexit(1)
     os.system("export TEXINPUTS=\".:@prefix@/share/gerris:\" " +\
                   "&& cd " + wdname + \
@@ -72,20 +72,20 @@ for d in sys.argv[1:]:
                   hname + \
                   "; mv " + hname + " " + wdir)
         
-    print "\n\n**** Successfully generated directory ****: " + example.name + "_html\n"
+    print("\n\n**** Successfully generated directory ****: " + example.name + "_html\n")
     files = example.name + "/" + example.name + ".gfs"
     for f in example.required:
         files += " " + example.name + "/" + f
     if os.system("tar czf " + example.name + ".tgz " + files):
-        print "**** Errors occured while generating file ****: " + example.name + ".tgz"
+        print("**** Errors occured while generating file ****: " + example.name + ".tgz")
         os.remove(example.name + ".tgz")
         myexit(1)
     status,msg = example.test()
     if status != None:
-        print "**** Errors occured while generating file ****: " + example.name + ".tgz"
-        print " ".join(msg)
+        print("**** Errors occured while generating file ****: " + example.name + ".tgz")
+        print(" ".join(msg))
         os.remove(example.name + ".tgz")
         myexit(1)
 
-    print "**** Successfully generated file ****: " + example.name + ".tgz"
+    print("**** Successfully generated file ****: " + example.name + ".tgz")
     os.system("rm -r -f " + wdname)
diff --git a/doc/examples/gfs2tex b/doc/examples/gfs2tex
index d2588a0..6223309 100644
--- a/doc/examples/gfs2tex
+++ b/doc/examples/gfs2tex
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys
 import os
diff --git a/doc/examples/gfs2tex.py b/doc/examples/gfs2tex.py
index e0da406..7c7f792 100644
--- a/doc/examples/gfs2tex.py
+++ b/doc/examples/gfs2tex.py
@@ -163,7 +163,7 @@ class Example:
             if len(record) > 0:
                 if record[0] == "user":
                     self.runtime = float(record[1])
-                    print >>open(self.path + "/runtime",'w'), self.runtime
+                    print(self.runtime, file=open(self.path + "/runtime",'w'))
                 elif record[0] != "real" and record[0] != "sys":
                     lines.append(l)
             else:
diff --git a/doc/examples/hump.sh b/doc/examples/hump.sh
index 64135cb..3c466c2 100755
--- a/doc/examples/hump.sh
+++ b/doc/examples/hump.sh
@@ -1 +1 @@
-python -u test.py hump
+python3 -u test.py hump
diff --git a/doc/examples/logo.sh b/doc/examples/logo.sh
index af27cf2..37c8638 100755
--- a/doc/examples/logo.sh
+++ b/doc/examples/logo.sh
@@ -1 +1 @@
-python -u test.py logo
+python3 -u test.py logo
diff --git a/doc/examples/monai.sh b/doc/examples/monai.sh
index 370be37..2ddfff1 100755
--- a/doc/examples/monai.sh
+++ b/doc/examples/monai.sh
@@ -1 +1 @@
-python -u test.py monai
+python3 -u test.py monai
diff --git a/doc/examples/plateau.sh b/doc/examples/plateau.sh
index 1090cf1..8e81dc9 100755
--- a/doc/examples/plateau.sh
+++ b/doc/examples/plateau.sh
@@ -1 +1 @@
-python -u test.py plateau
+python3 -u test.py plateau
diff --git a/doc/examples/rt.sh b/doc/examples/rt.sh
index e325c99..cbc68bf 100755
--- a/doc/examples/rt.sh
+++ b/doc/examples/rt.sh
@@ -1 +1 @@
-python -u test.py rt
+python3 -u test.py rt
diff --git a/doc/examples/ship.sh b/doc/examples/ship.sh
index bdb7bf9..ef872ae 100755
--- a/doc/examples/ship.sh
+++ b/doc/examples/ship.sh
@@ -1 +1 @@
-python -u test.py ship
+python3 -u test.py ship
diff --git a/doc/examples/shock.sh b/doc/examples/shock.sh
index 54a0367..ec926ea 100755
--- a/doc/examples/shock.sh
+++ b/doc/examples/shock.sh
@@ -1 +1 @@
-python -u test.py shock
+python3 -u test.py shock
diff --git a/doc/examples/starting.sh b/doc/examples/starting.sh
index 3944347..54d263b 100755
--- a/doc/examples/starting.sh
+++ b/doc/examples/starting.sh
@@ -1 +1 @@
-python -u test.py starting
+python3 -u test.py starting
diff --git a/doc/examples/tangaroa.sh b/doc/examples/tangaroa.sh
index af1f283..13d32e8 100755
--- a/doc/examples/tangaroa.sh
+++ b/doc/examples/tangaroa.sh
@@ -1 +1 @@
-python -u test.py tangaroa
+python3 -u test.py tangaroa
diff --git a/doc/examples/test.py b/doc/examples/test.py
index 797b612..d8af54c 100644
--- a/doc/examples/test.py
+++ b/doc/examples/test.py
@@ -11,12 +11,12 @@ for start in sys.argv[1:]:
             example = gfs2tex.Example(root)
             status,msg = example.test()
             if status != None:
-                print "FAIL:",root
+                print("FAIL:",root)
                 if len(msg) > 0:
-                    print " ".join(msg)
+                    print(" ".join(msg))
                 failed += 1
             else:
-                print "PASS:",root
+                print("PASS:",root)
             n += 1
 
 if failed:
@@ -24,9 +24,9 @@ if failed:
 else:
     msg = "All " + repr(n) + " tests passed"
 
-print len(msg)*"="
-print msg
-print len(msg)*"="
+print(len(msg)*"=")
+print(msg)
+print(len(msg)*"=")
 
 if failed:
     sys.exit(1)
diff --git a/doc/examples/tides.sh b/doc/examples/tides.sh
index ea25ab8..f6fe067 100755
--- a/doc/examples/tides.sh
+++ b/doc/examples/tides.sh
@@ -1 +1 @@
-python -u test.py tides
+python3 -u test.py tides
diff --git a/doc/examples/tsunami.sh b/doc/examples/tsunami.sh
index 0195683..b152e70 100755
--- a/doc/examples/tsunami.sh
+++ b/doc/examples/tsunami.sh
@@ -1 +1 @@
-python -u test.py tsunami
+python3 -u test.py tsunami
diff --git a/doc/examples/viscmix.sh b/doc/examples/viscmix.sh
index b6ae4a4..b740226 100755
--- a/doc/examples/viscmix.sh
+++ b/doc/examples/viscmix.sh
@@ -1 +1 @@
-python -u test.py viscmix
+python3 -u test.py viscmix
diff --git a/doc/examples/wingtip.sh b/doc/examples/wingtip.sh
index 1bf7a5c..5a0d5ad 100755
--- a/doc/examples/wingtip.sh
+++ b/doc/examples/wingtip.sh
@@ -1 +1 @@
-python -u test.py wingtip
+python3 -u test.py wingtip
diff --git a/test/Makefile.am b/test/Makefile.am
index ef0091a..eac5f05 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -24,7 +24,7 @@ TEXINPUTS = .:$(top_srcdir)/doc/examples:
 BIBINPUTS = $(top_srcdir)/doc
 
 Makefile.deps: template.tex depend.py Makefile.am
-	python depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
+	python3 depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
 	echo "" >> Makefile.deps
 	echo -n "TESTDIRS = " >> Makefile.deps
 	echo `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` >> Makefile.deps
@@ -33,7 +33,7 @@ include Makefile.deps
 
 tests.tex: template.tex Makefile.deps
 	rm -r -f tests
-	python gfs2tex $(TESTDIRS)
+	python3 gfs2tex $(TESTDIRS)
 	sed -e 's/\\test{\(.*\)\/\(.*\)}/\\input{\1\/\2\/\2.tex}/g' \
 	    -e 's/\\test{\(.*\)}/\\input{\1\/\1.tex}/g' < template.tex > tests.tex
 
diff --git a/test/Makefile.in b/test/Makefile.in
index 3961332..f545dca 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1439,7 +1439,7 @@ clean-generic:
 	mv -f summary.sh.bak summary.sh
 
 Makefile.deps: template.tex depend.py Makefile.am
-	python depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
+	python3 depend.py `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` > Makefile.deps
 	echo "" >> Makefile.deps
 	echo -n "TESTDIRS = " >> Makefile.deps
 	echo `grep \\test{[^/]*} < template.tex | sed 's/\\\\test{\(.*\)}/\1/g'` >> Makefile.deps
@@ -1917,7 +1917,7 @@ tests.tex: \
 
 tests.tex: template.tex Makefile.deps
 	rm -r -f tests
-	python gfs2tex $(TESTDIRS)
+	python3 gfs2tex $(TESTDIRS)
 	sed -e 's/\\test{\(.*\)\/\(.*\)}/\\input{\1\/\2\/\2.tex}/g' \
 	    -e 's/\\test{\(.*\)}/\\input{\1\/\1.tex}/g' < template.tex > tests.tex
 
diff --git a/test/advection.sh b/test/advection.sh
index 4048d7f..5760891 100755
--- a/test/advection.sh
+++ b/test/advection.sh
@@ -1 +1 @@
-python -u test.py advection
+python3 -u test.py advection
diff --git a/test/advection/advection.sh b/test/advection/advection.sh
index f165a2c..b31aaa1 100644
--- a/test/advection/advection.sh
+++ b/test/advection/advection.sh
@@ -54,7 +54,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
diff --git a/test/annulus.sh b/test/annulus.sh
index d8fab36..b09ae32 100755
--- a/test/annulus.sh
+++ b/test/annulus.sh
@@ -1 +1 @@
-python -u test.py annulus
+python3 -u test.py annulus
diff --git a/test/annulus/annulus.sh b/test/annulus/annulus.sh
index d1b2c2b..02ef169 100644
--- a/test/annulus/annulus.sh
+++ b/test/annulus/annulus.sh
@@ -42,7 +42,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
diff --git a/test/axi.sh b/test/axi.sh
index 109ea9e..5c12920 100755
--- a/test/axi.sh
+++ b/test/axi.sh
@@ -1 +1 @@
-python -u test.py axi
+python3 -u test.py axi
diff --git a/test/axi/axi.sh b/test/axi/axi.sh
index 5bb2bb1..e72ae2a 100644
--- a/test/axi/axi.sh
+++ b/test/axi/axi.sh
@@ -55,7 +55,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,3) - Curve('error.ref',1,3)).max() > 1e-5:
diff --git a/test/axi/viscous/viscous.sh b/test/axi/viscous/viscous.sh
index 765877f..dc36c38 100644
--- a/test/axi/viscous/viscous.sh
+++ b/test/axi/viscous/viscous.sh
@@ -38,11 +38,11 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('cp-12-100',1,2) - Curve('fadlun-cp-100',1,2)).norm2() > 1.6e-2:
-    print (Curve('cp-12-100',1,2) - Curve('fadlun-cp-100',1,2)).norm2()
+    print((Curve('cp-12-100',1,2) - Curve('fadlun-cp-100',1,2)).norm2())
     exit(1)
 EOF
 else
diff --git a/test/axiadvection.sh b/test/axiadvection.sh
index e47a378..a09c4ed 100755
--- a/test/axiadvection.sh
+++ b/test/axiadvection.sh
@@ -1 +1 @@
-python -u test.py axiadvection
+python3 -u test.py axiadvection
diff --git a/test/boundaries.sh b/test/boundaries.sh
index 8bf277a..ed7237a 100755
--- a/test/boundaries.sh
+++ b/test/boundaries.sh
@@ -1 +1 @@
-python -u test.py boundaries
+python3 -u test.py boundaries
diff --git a/test/boundaries/boundaries.sh b/test/boundaries/boundaries.sh
index af41c90..a3b4a6b 100644
--- a/test/boundaries/boundaries.sh
+++ b/test/boundaries/boundaries.sh
@@ -27,17 +27,17 @@ for v in U V; do
     done
 done
 
-if cat <<EOF | python > convergence.tex; then :
+if cat <<EOF | python3 > convergence.tex; then :
 from check import *
 from sys import *
 from math import *
 
 for component,variable in [('x','U'),('y','V')]:
-  print r"""\begin{table}[htbp]
+  print(r"""\begin{table}[htbp])
   \caption{"""
-  print r"\label{boundaries-" + component + "}"
-  print r"Errors and convergence rates for the \$"+component+r"\$-component of the velocity.}"  
-  print r"""\begin{center}
+  print(r"\label{boundaries-" + component + "}")
+  print(r"Errors and convergence rates for the \$"+component+r"\$-component of the velocity.}"  )
+  print(r"""\begin{center})
   \begin{tabular}{||l|c|c|c||c|c|c||} \hline
            & \multicolumn{3}{c||}{All cells} & \multicolumn{3}{c||}{Full 128 cells} \\\ \hline
            & 128-256  & Rate & 256-512  & 128-256  & Rate & 256-512  \\\ \hline"""
@@ -45,21 +45,21 @@ for component,variable in [('x','U'),('y','V')]:
   for i,name in [(2,r"\$L_1\$"),(3,r"\$L_2\$"),(4,r"\$L_\infty\$")]:
     a=Curve('order'+variable,1,i)
     b=Curve('orderf'+variable,1,i)
-    print name,
-    print "& %.2e & %4.2f & %.2e & %.2e & %4.2f & %.2e" % (\
+    print(name,)
+    print("& %.2e & %4.2f & %.2e & %.2e & %4.2f & %.2e" % (\)
     a.l[0][1], log(a.l[0][1]/a.l[1][1])/log(2.), a.l[1][1], \
     b.l[0][1], log(b.l[0][1]/b.l[1][1])/log(2.), b.l[1][1]),
-    print r"\\\"
+    print(r"\\\")
 
     a=Curve('order'+variable+'.ref',1,i)
     b=Curve('orderf'+variable+'.ref',1,i)
-    print "& {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e} & {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e}" % (\
+    print("& {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e} & {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e}" % (\)
     a.l[0][1], log(a.l[0][1]/a.l[1][1])/log(2.), a.l[1][1], \
     b.l[0][1], log(b.l[0][1]/b.l[1][1])/log(2.), b.l[1][1]),
-    print r"\\\"
+    print(r"\\\")
 
-  print r"\hline"
-  print r"""\end{tabular}
+  print(r"\hline")
+  print(r"""\end{tabular})
   \end{center}
   \end{table}"""
 EOF
@@ -67,7 +67,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 
diff --git a/test/bump.sh b/test/bump.sh
index f4e4da4..9a173f2 100755
--- a/test/bump.sh
+++ b/test/bump.sh
@@ -1 +1 @@
-python -u test.py bump
+python3 -u test.py bump
diff --git a/test/bump/bump.sh b/test/bump/bump.sh
index 1944c48..ecc908b 100644
--- a/test/bump/bump.sh
+++ b/test/bump/bump.sh
@@ -79,18 +79,18 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 if (Curve('norms-explicit',3,7) - Curve('norms-explicit.ref',3,7)).max() > 1e-5 or \
    (Curve('norms-explicit',3,9) - Curve('norms-explicit.ref',3,9)).max() > 1e-5 or \
    (Curve('norms-implicit',3,7) - Curve('norms-implicit.ref',3,7)).max() > 1e-5 or \
    (Curve('norms-implicit',3,9) - Curve('norms-implicit.ref',3,9)).max() > 1e-5:
-    print (Curve('norms-explicit',3,7) - Curve('norms-explicit.ref',3,7)).max()
-    print (Curve('norms-explicit',3,9) - Curve('norms-explicit.ref',3,9)).max()
-    print (Curve('norms-explicit',3,7) - Curve('norms-explicit.ref',3,7)).max()
-    print (Curve('norms-explicit',3,9) - Curve('norms-explicit.ref',3,9)).max()
-    print (Curve('norms-implicit',3,7) - Curve('norms-implicit.ref',3,7)).max()
-    print (Curve('norms-implicit',3,9) - Curve('norms-implicit.ref',3,9)).max()
+    print((Curve('norms-explicit',3,7) - Curve('norms-explicit.ref',3,7)).max())
+    print((Curve('norms-explicit',3,9) - Curve('norms-explicit.ref',3,9)).max())
+    print((Curve('norms-explicit',3,7) - Curve('norms-explicit.ref',3,7)).max())
+    print((Curve('norms-explicit',3,9) - Curve('norms-explicit.ref',3,9)).max())
+    print((Curve('norms-implicit',3,7) - Curve('norms-implicit.ref',3,7)).max())
+    print((Curve('norms-implicit',3,9) - Curve('norms-implicit.ref',3,9)).max())
     exit(1)
 EOF
 else
diff --git a/test/capwave.sh b/test/capwave.sh
index a019a8b..a40ed43 100755
--- a/test/capwave.sh
+++ b/test/capwave.sh
@@ -1 +1 @@
-python -u test.py capwave
+python3 -u test.py capwave
diff --git a/test/capwave/capwave.sh b/test/capwave/capwave.sh
index 40ce243..7b7522b 100644
--- a/test/capwave/capwave.sh
+++ b/test/capwave/capwave.sh
@@ -63,7 +63,7 @@ EOF
     fi
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('convergence',1,2) - Curve('convergence.ref',1,2)).max() > 1e-5:
diff --git a/test/channel.sh b/test/channel.sh
index 9ca746c..90f4aba 100755
--- a/test/channel.sh
+++ b/test/channel.sh
@@ -1 +1 @@
-python -u test.py channel
+python3 -u test.py channel
diff --git a/test/channel/channel.sh b/test/channel/channel.sh
index 61a7a13..f1e2734 100644
--- a/test/channel/channel.sh
+++ b/test/channel/channel.sh
@@ -28,17 +28,17 @@ for v in U V; do
     done
 done
 
-if cat <<EOF | python > convergence.tex; then :
+if cat <<EOF | python3 > convergence.tex; then :
 from check import *
 from sys import *
 from math import *
 
 for component,variable in [('x','U'),('y','V')]:
-  print r"""\begin{table}[htbp]
+  print(r"""\begin{table}[htbp])
   \caption{"""
-  print r"\label{channel-" + component + "}"
-  print r"Errors and convergence rates for the \$"+component+r"\$-component of the velocity.}"
-  print r"""\begin{center}
+  print(r"\label{channel-" + component + "}")
+  print(r"Errors and convergence rates for the \$"+component+r"\$-component of the velocity.}")
+  print(r"""\begin{center})
   \begin{tabular}{||l|c|c|c||c|c|c||} \hline
            & \multicolumn{3}{c||}{All cells} & \multicolumn{3}{c||}{Full 128 cells} \\\ \hline
            & 128-256  & Rate & 256-512  & 128-256  & Rate & 256-512  \\\ \hline"""
@@ -46,21 +46,21 @@ for component,variable in [('x','U'),('y','V')]:
   for i,name in [(2,r"\$L_1\$"),(3,r"\$L_2\$"),(4,r"\$L_\infty\$")]:
     a=Curve('order'+variable,1,i)
     b=Curve('orderf'+variable,1,i)
-    print name,
-    print "& %.2e & %4.2f & %.2e & %.2e & %4.2f & %.2e" % (\
+    print(name,)
+    print("& %.2e & %4.2f & %.2e & %.2e & %4.2f & %.2e" % (\)
     a.l[0][1], log(a.l[0][1]/a.l[1][1])/log(2.), a.l[1][1], \
     b.l[0][1], log(b.l[0][1]/b.l[1][1])/log(2.), b.l[1][1]),
-    print r"\\\"
+    print(r"\\\")
 
     a=Curve('order'+variable+'.ref',1,i)
     b=Curve('orderf'+variable+'.ref',1,i)
-    print "& {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e} & {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e}" % (\
+    print("& {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e} & {\color{blue}%.2e} & {\color{blue}%4.2f} & {\color{blue}%.2e}" % (\)
     a.l[0][1], log(a.l[0][1]/a.l[1][1])/log(2.), a.l[1][1], \
     b.l[0][1], log(b.l[0][1]/b.l[1][1])/log(2.), b.l[1][1]),
-    print r"\\\"
+    print(r"\\\")
 
-  print r"\hline"
-  print r"""\end{tabular}
+  print(r"\hline")
+  print(r"""\end{tabular})
   \end{center}
   \end{table}"""
 EOF
@@ -68,7 +68,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 
diff --git a/test/check.py b/test/check.py
index 79a5cbd..255c6c5 100644
--- a/test/check.py
+++ b/test/check.py
@@ -66,4 +66,4 @@ class Curve:
 		return self.max(lambda x: abs(x))
 	def write(self):
 		for p in self.l:
-			print p[0],p[1]
+			print(p[0],p[1])
diff --git a/test/circle.sh b/test/circle.sh
index c48cb75..95603a2 100755
--- a/test/circle.sh
+++ b/test/circle.sh
@@ -1 +1 @@
-python -u test.py circle
+python3 -u test.py circle
diff --git a/test/circle/circle.sh b/test/circle/circle.sh
index 633f6fd..7137521 100644
--- a/test/circle/circle.sh
+++ b/test/circle/circle.sh
@@ -103,17 +103,17 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max() > 1e-8 or\
    (Curve('res-7-hypre',1,3) - Curve('res-7.ref',1,7)).max() > 1e-8 or\
    (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max() > 1e-6 or\
    (Curve('error-hypre',1,4) - Curve('error.ref',1,8)).max() > 1e-6:
-    print (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max()
-    print (Curve('res-7-hypre',1,3) - Curve('res-7.ref',1,7)).max()
-    print (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max()
-    print (Curve('error-hypre',1,4) - Curve('error.ref',1,8)).max()
+    print((Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max())
+    print((Curve('res-7-hypre',1,3) - Curve('res-7.ref',1,7)).max())
+    print((Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max())
+    print((Curve('error-hypre',1,4) - Curve('error.ref',1,8)).max())
     exit(1)
 EOF
 else
diff --git a/test/conservation.sh b/test/conservation.sh
index ddc548c..8b5092c 100755
--- a/test/conservation.sh
+++ b/test/conservation.sh
@@ -1 +1 @@
-python -u test.py conservation
+python3 -u test.py conservation
diff --git a/test/coriolis.sh b/test/coriolis.sh
index 8289e14..0e425bb 100755
--- a/test/coriolis.sh
+++ b/test/coriolis.sh
@@ -1 +1 @@
-python -u test.py coriolis
+python3 -u test.py coriolis
diff --git a/test/coriolis/coriolis.sh b/test/coriolis/coriolis.sh
index 2a9f4a3..d56adf0 100644
--- a/test/coriolis/coriolis.sh
+++ b/test/coriolis/coriolis.sh
@@ -40,7 +40,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error.dat',1,2)).max() > 1e-6:
diff --git a/test/cosine.sh b/test/cosine.sh
index c96658c..64576ea 100755
--- a/test/cosine.sh
+++ b/test/cosine.sh
@@ -1 +1 @@
-python -u test.py cosine
+python3 -u test.py cosine
diff --git a/test/cosine/cosine.sh b/test/cosine/cosine.sh
index 06c9a9f..44529d8 100644
--- a/test/cosine/cosine.sh
+++ b/test/cosine/cosine.sh
@@ -53,14 +53,14 @@ EOF
     fi
 done
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 c = Curve()
-print (Curve('error-45',1,4) - Curve('error-45.ref',1,4)).max()
-print (Curve('error-45',1,5) - Curve('error-45.ref',1,5)).max()
-print (Curve('error-90',1,4) - Curve('error-90.ref',1,4)).max()
-print (Curve('error-90',1,5) - Curve('error-90.ref',1,5)).max() 
+print((Curve('error-45',1,4) - Curve('error-45.ref',1,4)).max())
+print((Curve('error-45',1,5) - Curve('error-45.ref',1,5)).max())
+print((Curve('error-90',1,4) - Curve('error-90.ref',1,4)).max())
+print((Curve('error-90',1,5) - Curve('error-90.ref',1,5)).max() )
 if (Curve('error-45',1,4) - Curve('error-45.ref',1,4)).max() > 1e-10 or\
    (Curve('error-45',1,5) - Curve('error-45.ref',1,5)).max() > 1e-10 or\
    (Curve('error-90',1,4) - Curve('error-90.ref',1,4)).max() > 1e-10 or\
diff --git a/test/couette.sh b/test/couette.sh
index a225c21..6875ef2 100755
--- a/test/couette.sh
+++ b/test/couette.sh
@@ -1 +1 @@
-python -u test.py couette
+python3 -u test.py couette
diff --git a/test/couette/couette.sh b/test/couette/couette.sh
index da152fd..6d274e1 100644
--- a/test/couette/couette.sh
+++ b/test/couette/couette.sh
@@ -24,13 +24,13 @@ else
    exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
-print (Curve('prof-0',1,2) - Curve('prof-0.ref',1,2)).norm2(),\
+print((Curve('prof-0',1,2) - Curve('prof-0.ref',1,2)).norm2(),\
    (Curve('prof-1',1,2) - Curve('prof-1.ref',1,2)).norm2(),\
    (Curve('prof-2',1,2) - Curve('prof-2.ref',1,2)).norm2(),\
-   (Curve('prof-3',1,2) - Curve('prof-3.ref',1,2)).norm2()
+   (Curve('prof-3',1,2) - Curve('prof-3.ref',1,2)).norm2())
 if (Curve('prof-0',1,2) - Curve('prof-0.ref',1,2)).norm2() > 3.6e-4 or \
    (Curve('prof-1',1,2) - Curve('prof-1.ref',1,2)).norm2() > 6.3e-4 or \
    (Curve('prof-2',1,2) - Curve('prof-2.ref',1,2)).norm2() > 21e-4 or \
diff --git a/test/cylinder.sh b/test/cylinder.sh
index 73135b6..c0390c4 100755
--- a/test/cylinder.sh
+++ b/test/cylinder.sh
@@ -1 +1 @@
-python -u test.py cylinder
+python3 -u test.py cylinder
diff --git a/test/cylinder/cylinder.sh b/test/cylinder/cylinder.sh
index e51c5a2..e0df96e 100644
--- a/test/cylinder/cylinder.sh
+++ b/test/cylinder/cylinder.sh
@@ -83,12 +83,12 @@ for level in 6 7 8; do
 done
 
 # check error norms
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 if (Curve('norms',1,8) - Curve('norms.ref',1,8)).max() > 1e-5 or \
    (Curve('norms',1,10) - Curve('norms.ref',1,10)).max() > 1e-5:
-    print (Curve('norms',1,8) - Curve('norms.ref',1,8)).max()
-    print (Curve('norms',1,10) - Curve('norms.ref',1,10)).max()
+    print((Curve('norms',1,8) - Curve('norms.ref',1,8)).max())
+    print((Curve('norms',1,10) - Curve('norms.ref',1,10)).max())
     exit(1)
 EOF
 else
diff --git a/test/debye.sh b/test/debye.sh
index 831ec66..4ccc545 100755
--- a/test/debye.sh
+++ b/test/debye.sh
@@ -1 +1 @@
-python -u test.py debye
+python3 -u test.py debye
diff --git a/test/debye/debye.sh b/test/debye/debye.sh
index 27f2172..c659aab 100644
--- a/test/debye/debye.sh
+++ b/test/debye/debye.sh
@@ -21,12 +21,12 @@ else
     exit 1
 fi
  
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
-print (Curve('profile',1,2) - Curve('analytical',1,2)).normi()
-print (Curve('profile',1,3) - Curve('analytical',1,3)).normi()
-print (Curve('profile',1,4) - Curve('analytical',1,4)).normi()
+print((Curve('profile',1,2) - Curve('analytical',1,2)).normi())
+print((Curve('profile',1,3) - Curve('analytical',1,3)).normi())
+print((Curve('profile',1,4) - Curve('analytical',1,4)).normi())
 if (Curve('profile',1,2) - Curve('analytical',1,2)).normi() > 1.6e-3 or \
    (Curve('profile',1,3) - Curve('analytical',1,3)).normi() > 6.9e-3 or \
    (Curve('profile',1,4) - Curve('analytical',1,4)).normi() > 6.77e-3:
diff --git a/test/depend.py b/test/depend.py
index fc2eeb6..f2b3b73 100644
--- a/test/depend.py
+++ b/test/depend.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys
 import os
@@ -6,8 +6,8 @@ import os.path
 sys.path.append("../doc/examples")
 import gfs2tex
 
-print "## File generated automatically by depend.py: do not modify by hand"
-print ""
+print("## File generated automatically by depend.py: do not modify by hand")
+print()
 
 dists = ""
 depends = ""
@@ -20,9 +20,9 @@ for start in sys.argv[1:]:
     reps += " " + start
     logs += "\\\n\t" + start + ".log"
     f = open(start + ".sh", "w")
-    f.write("python -u test.py " + start + "\n")
+    f.write("python3 -u test.py " + start + "\n")
     f.close()
-    os.chmod(start + ".sh",0755)
+    os.chmod(start + ".sh",0o755)
     for root, dirs, files in os.walk(start,topdown=True):
         if not ".xvpics" in root:
             test = gfs2tex.Example(root)
@@ -38,15 +38,22 @@ for start in sys.argv[1:]:
                 if f[-4:] == ".mpg" or f[-4:] == ".ogv" or f[-4:] == ".png" or f[-4:] == ".mp4":
                     docs += "\\\n\t" + test.path + "/" + f
 
-print "DOCS = " + docs + dists
-print ""
-print "TESTS = " + tests + "\\\n\tsummary.sh"
-os.chmod("summary.sh",0755)
-print ""
-print "EXTRA_DIST += $(TESTS)" + dists
-print ""
-print "TESTS_ENVIRONMENT = TESTS=\"" + reps + "\""
-print "TEST_EXTENSIONS = .sh"
-print "summary.log:" + logs
-print ""
-print "tests.tex: " + depends
+print("DOCS = " + docs + dists)
+print()
+print("TESTS = " + tests + "\\\n\tsummary.sh")
+os.chmod("summary.sh",0o755)
+print()
+print("EXTRA_DIST += $(TESTS)" + dists)
+print()
+print("TESTS_ENVIRONMENT = TESTS=\"" + reps + "\"")
+print("TEST_EXTENSIONS = .sh")
+print("summary.log:" + logs)
+print()
+print("TESTS = " + tests + "\\\n\tsummary.sh")
+os.chmod("summary.sh",0o755)
+print()
+print("TESTS_ENVIRONMENT = TESTS=\"" + reps + "\"")
+print("TEST_EXTENSIONS = .sh")
+print("summary.log:" + logs)
+print()
+print("tests.tex: " + depends)
diff --git a/test/diffusion.sh b/test/diffusion.sh
index 11cb2fb..8e97b16 100755
--- a/test/diffusion.sh
+++ b/test/diffusion.sh
@@ -1 +1 @@
-python -u test.py diffusion
+python3 -u test.py diffusion
diff --git a/test/dumbell.sh b/test/dumbell.sh
index 2da627c..1b43054 100755
--- a/test/dumbell.sh
+++ b/test/dumbell.sh
@@ -1 +1 @@
-python -u test.py dumbell
+python3 -u test.py dumbell
diff --git a/test/electro.sh b/test/electro.sh
index d2ef706..e486b1f 100755
--- a/test/electro.sh
+++ b/test/electro.sh
@@ -1 +1 @@
-python -u test.py electro
+python3 -u test.py electro
diff --git a/test/electro/electro.sh b/test/electro/electro.sh
index 51e6dec..8896e02 100644
--- a/test/electro/electro.sh
+++ b/test/electro/electro.sh
@@ -54,13 +54,13 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 c = Curve()
-print (Curve('convergence',1,2) - Curve('convergence.ref',1,2)).max()
-print (Curve('convergence',1,3) - Curve('convergence.ref',1,3)).max()
-print Curve('rhoe',3,5).max()
+print((Curve('convergence',1,2) - Curve('convergence.ref',1,2)).max())
+print((Curve('convergence',1,3) - Curve('convergence.ref',1,3)).max())
+print(Curve('rhoe',3,5).max())
 if (Curve('convergence',1,2) - Curve('convergence.ref',1,2)).max() > 1e-6 or\
    (Curve('convergence',1,3) - Curve('convergence.ref',1,3)).max() > 1e-6 or\
     Curve('rhoe',3,5).max() > 1e-9:
diff --git a/test/gaussian.sh b/test/gaussian.sh
index ff6a889..46e74ca 100755
--- a/test/gaussian.sh
+++ b/test/gaussian.sh
@@ -1 +1 @@
-python -u test.py gaussian
+python3 -u test.py gaussian
diff --git a/test/gaussian/gaussian.sh b/test/gaussian/gaussian.sh
index 5ae6cd5..07b3820 100644
--- a/test/gaussian/gaussian.sh
+++ b/test/gaussian/gaussian.sh
@@ -11,16 +11,16 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 avg = (Curve('prof.ref',1,2) - Curve('prof.dat',3,5)).mean()
-print avg
+print(avg)
 c = Curve()
 for p in Curve('prof.dat',3,5).l:
     c.l.append((p[0], p[1] + avg))
 if (Curve('prof.ref',1,2) - c).normi() > $emax:
-   print (Curve('prof.ref',1,2) - c).normi()
+   print((Curve('prof.ref',1,2) - c).normi())
    exit(1)
 EOF
 else
diff --git a/test/geo.sh b/test/geo.sh
index 4816ef5..312d30b 100755
--- a/test/geo.sh
+++ b/test/geo.sh
@@ -1 +1 @@
-python -u test.py geo
+python3 -u test.py geo
diff --git a/test/geo/beta/beta.sh b/test/geo/beta/beta.sh
index a62c8e6..25c5195 100644
--- a/test/geo/beta/beta.sh
+++ b/test/geo/beta/beta.sh
@@ -23,7 +23,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if Curve('energy',1,2).max() > 1. or \
diff --git a/test/geo/geo.sh b/test/geo/geo.sh
index e3f6f65..43309d2 100644
--- a/test/geo/geo.sh
+++ b/test/geo/geo.sh
@@ -5,7 +5,7 @@ if test x$donotrun != xtrue; then
     gerris3D $1
 fi
 
-python <<EOF
+python3 <<EOF
 from check import *
 from sys import *
 if (Curve('e',1,2) - Curve('e.ref',1,2)).max() > 1e-3:
diff --git a/test/geo/river/geo.sh b/test/geo/river/geo.sh
index 6c01c3f..6cda3bf 100644
--- a/test/geo/river/geo.sh
+++ b/test/geo/river/geo.sh
@@ -5,7 +5,7 @@ if test x$donotrun != xtrue; then
     gerris2D $1
 fi
 
-python <<EOF
+python3 <<EOF
 from check import *
 from sys import *
 if (Curve('e',1,2) - Curve('e.ref',1,2)).max() > 1e-3:
diff --git a/test/gfs2tex b/test/gfs2tex
index 0cb556c..d377e9a 100644
--- a/test/gfs2tex
+++ b/test/gfs2tex
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys
 import os
diff --git a/test/groundwater.sh b/test/groundwater.sh
index bded8f1..89b0d59 100755
--- a/test/groundwater.sh
+++ b/test/groundwater.sh
@@ -1 +1 @@
-python -u test.py groundwater
+python3 -u test.py groundwater
diff --git a/test/groundwater/groundwater.sh b/test/groundwater/groundwater.sh
index 150d8e4..7cbcd99 100644
--- a/test/groundwater/groundwater.sh
+++ b/test/groundwater/groundwater.sh
@@ -36,17 +36,17 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('p',1,2) - Curve('p.ref',1,2)).max() > 1e-8 or\
    (Curve('p',1,3) - Curve('p.ref',1,3)).max() > 1e-6:
-    print (Curve('p',1,2) - Curve('p.ref',1,2)).max()
-    print (Curve('p',1,3) - Curve('p.ref',1,3)).max()
+    print((Curve('p',1,2) - Curve('p.ref',1,2)).max())
+    print((Curve('p',1,3) - Curve('p.ref',1,3)).max())
     exit(1)
 if (Curve('U',1,2) - Curve('U.ref',1,2)).max() > 1e-8 or\
    (Curve('U',1,3) - Curve('U.ref',1,3)).max() > 1e-6:
-    print (Curve('U',1,2) - Curve('U.ref',1,2)).max()
+    print((Curve('U',1,2) - Curve('U.ref',1,2)).max())
     exit(1)
 EOF
 else
diff --git a/test/harmonic.sh b/test/harmonic.sh
index 37ba82d..f1cd20c 100755
--- a/test/harmonic.sh
+++ b/test/harmonic.sh
@@ -1 +1 @@
-python -u test.py harmonic
+python3 -u test.py harmonic
diff --git a/test/harmonic/harmonic.sh b/test/harmonic/harmonic.sh
index 460110e..6ffaac6 100644
--- a/test/harmonic/harmonic.sh
+++ b/test/harmonic/harmonic.sh
@@ -93,13 +93,13 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max() > 1e-8 or\
    (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
-    print (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max()
-    print (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max()
+    print((Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max())
+    print((Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max())
     exit(1)
 EOF
 else
diff --git a/test/height.sh b/test/height.sh
index 61dad9a..ddb3454 100755
--- a/test/height.sh
+++ b/test/height.sh
@@ -1 +1 @@
-python -u test.py height
+python3 -u test.py height
diff --git a/test/hexagon.sh b/test/hexagon.sh
index 9274830..cde0298 100755
--- a/test/hexagon.sh
+++ b/test/hexagon.sh
@@ -1 +1 @@
-python -u test.py hexagon
+python3 -u test.py hexagon
diff --git a/test/hexagon/hexagon.sh b/test/hexagon/hexagon.sh
index 931eab9..cd08c01 100644
--- a/test/hexagon/hexagon.sh
+++ b/test/hexagon/hexagon.sh
@@ -27,7 +27,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if Curve('tracersum-1',1,2).normi() > 1e-6 or \
diff --git a/test/hydrostatic.sh b/test/hydrostatic.sh
index d391cdc..b409b7c 100755
--- a/test/hydrostatic.sh
+++ b/test/hydrostatic.sh
@@ -1 +1 @@
-python -u test.py hydrostatic
+python3 -u test.py hydrostatic
diff --git a/test/injectionaxi.sh b/test/injectionaxi.sh
index baa980e..ccc88d1 100755
--- a/test/injectionaxi.sh
+++ b/test/injectionaxi.sh
@@ -1 +1 @@
-python -u test.py injectionaxi
+python3 -u test.py injectionaxi
diff --git a/test/kinetic.sh b/test/kinetic.sh
index da1266e..1093396 100755
--- a/test/kinetic.sh
+++ b/test/kinetic.sh
@@ -1 +1 @@
-python -u test.py kinetic
+python3 -u test.py kinetic
diff --git a/test/lake.sh b/test/lake.sh
index d381ef4..15b31ad 100755
--- a/test/lake.sh
+++ b/test/lake.sh
@@ -1 +1 @@
-python -u test.py lake
+python3 -u test.py lake
diff --git a/test/lake/river/river.sh b/test/lake/river/river.sh
index 89b4950..3514843 100644
--- a/test/lake/river/river.sh
+++ b/test/lake/river/river.sh
@@ -47,11 +47,11 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('error',1,2) - Curve('error.ref',1,2)).max() > 1e-6:
-    print (Curve('error',1,2) - Curve('error.ref',1,2)).max()
+    print((Curve('error',1,2) - Curve('error.ref',1,2)).max())
     exit(1)
 EOF
 else
diff --git a/test/lake/stratified/stratified.sh b/test/lake/stratified/stratified.sh
index 5504afb..a0cb2363 100644
--- a/test/lake/stratified/stratified.sh
+++ b/test/lake/stratified/stratified.sh
@@ -82,11 +82,11 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('error',1,2) - Curve('error.ref',1,2)).max() > 1e-6:
-    print (Curve('error',1,2) - Curve('error.ref',1,2)).max()
+    print((Curve('error',1,2) - Curve('error.ref',1,2)).max())
     exit(1)
 EOF
 else
diff --git a/test/lid.sh b/test/lid.sh
index 2f396f4..df8527d 100755
--- a/test/lid.sh
+++ b/test/lid.sh
@@ -1 +1 @@
-python -u test.py lid
+python3 -u test.py lid
diff --git a/test/lid/explicit/lid.sh b/test/lid/explicit/lid.sh
index 4ebb337..8c256d4 100644
--- a/test/lid/explicit/lid.sh
+++ b/test/lid/explicit/lid.sh
@@ -5,11 +5,11 @@ if test x$donotrun != xtrue; then
     fi
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
-print (Curve('xprof',3,7) - Curve('../xprof.ghia',1,2)).normi()
-print (Curve('yprof',2,8) - Curve('../yprof.ghia',1,2)).normi()
+print((Curve('xprof',3,7) - Curve('../xprof.ghia',1,2)).normi())
+print((Curve('yprof',2,8) - Curve('../yprof.ghia',1,2)).normi())
 if (Curve('xprof',3,7) - Curve('../xprof.ghia',1,2)).normi() > 2.2e-2 or \
    (Curve('yprof',2,8) - Curve('../yprof.ghia',1,2)).normi() > 2.1e-2:
     exit(1)
diff --git a/test/lid/lid.sh b/test/lid/lid.sh
index 6665fc0..8127cce 100644
--- a/test/lid/lid.sh
+++ b/test/lid/lid.sh
@@ -5,13 +5,13 @@ if test x$donotrun != xtrue; then
     fi
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('xprof',3,7) - Curve('xprof.ghia',1,2)).normi() > 2e-2 or \
    (Curve('yprof',2,8) - Curve('yprof.ghia',1,2)).normi() > 1.7e-2:
-    print (Curve('xprof',3,7) - Curve('xprof.ghia',1,2)).normi()
-    print (Curve('yprof',2,8) - Curve('yprof.ghia',1,2)).normi()
+    print((Curve('xprof',3,7) - Curve('xprof.ghia',1,2)).normi())
+    print((Curve('yprof',2,8) - Curve('yprof.ghia',1,2)).normi())
     exit(1)
 EOF
 else
diff --git a/test/lonlat.sh b/test/lonlat.sh
index 4c677a8..bb229a9 100755
--- a/test/lonlat.sh
+++ b/test/lonlat.sh
@@ -1 +1 @@
-python -u test.py lonlat
+python3 -u test.py lonlat
diff --git a/test/merging.sh b/test/merging.sh
index 0d36185..67383d2 100755
--- a/test/merging.sh
+++ b/test/merging.sh
@@ -1 +1 @@
-python -u test.py merging
+python3 -u test.py merging
diff --git a/test/merging/merging.sh b/test/merging/merging.sh
index fb7a33c..044480c 100644
--- a/test/merging/merging.sh
+++ b/test/merging/merging.sh
@@ -39,46 +39,46 @@ for s in sim simc; do
     done
 done
 
-if cat <<EOF | python > convergence.tex ; then :
+if cat <<EOF | python3 > convergence.tex ; then :
 from check import *
 from sys import *
 from math import *
 
-print r"""\begin{tabular}{|c|c|c|c|c|c|}\hline
+print(r"""\begin{tabular}{|c|c|c|c|c|c|}\hline)
 Domain   & \multicolumn{5}{c|}{\$L_2\$}\\\ \hline
          & \$L=6\$   & \$O_2\$ & \$L=7\$    & \$O_2\$ & \$L=8\$  \\\ \hline"""
 
 def order(r,color='black'):
    for i in range(0,len(r.l)-1):
      y0,y1 = r.l[i][1],r.l[i+1][1]
-     print '& {\color{%s}%.2e} & {\color{%s}%4.2f}' % (color, y0, color, log(y0/y1)/log(2.)),
-   print '& {\color{%s}%.2e}' % (color, r.l[i+1][1]), r'\\\'
+     print('& {\color{%s}%.2e} & {\color{%s}%4.2f}' % (color, y0, color, log(y0/y1)/log(2.)),)
+   print('& {\color{%s}%.2e}' % (color, r.l[i+1][1]), r'\\\')
 
-print 'Circle',
+print('Circle', end=' ')
 order(Curve('simc.err',1,2))
 order(Curve('simc.err.ref',1,2), 'blue')
-print 'Adaptive',
+print('Adaptive', end=' ')
 order(Curve('sim.err',1,2))
 order(Curve('sim.err.ref',1,2), 'blue')
 
-print r"""\hline
+print(r"""\hline)
 Domain   & \multicolumn{5}{c|}{\$L_\infty\$} \\\ \hline
          &  \$L=6\$   & \$O_\infty\$ & \$L=7\$   & \$O_\infty\$ & \$L=8\$ \\\ \hline"""
 
-print 'Circle',
+print('Circle', end=' ')
 order(Curve('simc.err',1,3))
 order(Curve('simc.err.ref',1,3), 'blue')
-print 'Adaptive',
+print('Adaptive', end=' ')
 order(Curve('sim.err',1,3))
 order(Curve('sim.err.ref',1,3), 'blue')
 
-print r"\hline\end{tabular}"
+print(r"\hline\end{tabular}")
 EOF
 else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('sim.err',1,2) - Curve('sim.err.ref',1,2)).max() > 1e-6 or\
diff --git a/test/nonlinear.sh b/test/nonlinear.sh
index 885b21d..a83a747 100755
--- a/test/nonlinear.sh
+++ b/test/nonlinear.sh
@@ -1 +1 @@
-python -u test.py nonlinear
+python3 -u test.py nonlinear
diff --git a/test/nonlinear/nonlinear.sh b/test/nonlinear/nonlinear.sh
index a780760..f34eb1c 100644
--- a/test/nonlinear/nonlinear.sh
+++ b/test/nonlinear/nonlinear.sh
@@ -31,14 +31,14 @@ EOF
 	gfsview-batch3D end-ocean-$omega.gfs error-ocean.gfv
 done
 
-python <<EOF
+python3 <<EOF
 from check import *
 from sys import *
 if (Curve('error-1',3,9) - Curve('error-1.ref',3,9)).max() > 1e-7 or\
    (Curve('error-river-1',3,9) - Curve('error-river-1.ref',3,9)).max() > 1e-7 or\
    (Curve('error-ocean-1',3,9) - Curve('error-ocean-1.ref',3,9)).max() > 1e-7:
-    print (Curve('error-1',3,9) - Curve('error-1.ref',3,9)).max()
-    print (Curve('error-river-1',3,9) - Curve('error-river-1.ref',3,9)).max()
-    print (Curve('error-ocean-1',3,9) - Curve('error-ocean-1.ref',3,9)).max()
+    print((Curve('error-1',3,9) - Curve('error-1.ref',3,9)).max())
+    print((Curve('error-river-1',3,9) - Curve('error-river-1.ref',3,9)).max())
+    print((Curve('error-ocean-1',3,9) - Curve('error-ocean-1.ref',3,9)).max())
     exit(1)
 EOF
diff --git a/test/nz.sh b/test/nz.sh
index 3985930..98c5c11 100755
--- a/test/nz.sh
+++ b/test/nz.sh
@@ -1 +1 @@
-python -u test.py nz
+python3 -u test.py nz
diff --git a/test/oscillation.sh b/test/oscillation.sh
index 8093c42..7770ba8 100755
--- a/test/oscillation.sh
+++ b/test/oscillation.sh
@@ -1 +1 @@
-python -u test.py oscillation
+python3 -u test.py oscillation
diff --git a/test/oscillation/oscillation.sh b/test/oscillation/oscillation.sh
index b3ed1f9..e31a2b4 100644
--- a/test/oscillation/oscillation.sh
+++ b/test/oscillation/oscillation.sh
@@ -78,7 +78,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('fit',1,3) - Curve('fit.ref',1,3)).max() > 1e-2 or\
diff --git a/test/parabola.sh b/test/parabola.sh
index 0401115..597de43 100755
--- a/test/parabola.sh
+++ b/test/parabola.sh
@@ -1 +1 @@
-python -u test.py parabola
+python3 -u test.py parabola
diff --git a/test/parabola/parabola.sh b/test/parabola/parabola.sh
index 950a42c..514f084 100644
--- a/test/parabola/parabola.sh
+++ b/test/parabola/parabola.sh
@@ -128,11 +128,11 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-4:
-    print (Curve('error',1,4) - Curve('error.ref',1,4)).max()
+    print((Curve('error',1,4) - Curve('error.ref',1,4)).max())
     exit(1)
 EOF
 else
diff --git a/test/periodic.sh b/test/periodic.sh
index 3ab6981..22ca1e9 100755
--- a/test/periodic.sh
+++ b/test/periodic.sh
@@ -1 +1 @@
-python -u test.py periodic
+python3 -u test.py periodic
diff --git a/test/periodic/periodic.sh b/test/periodic/periodic.sh
index 59e0531..20b6c22 100644
--- a/test/periodic/periodic.sh
+++ b/test/periodic/periodic.sh
@@ -16,52 +16,52 @@ if test x$donotrun != xtrue; then
     done
 fi
 
-if cat <<EOF | python > minion1.tex; then :
+if cat <<EOF | python3 > minion1.tex; then :
 from check import *
 from sys import *
 from math import *
 
-print r"""\begin{tabular}{|c|c|c|c|c|c|}\hline
+print(r"""\begin{tabular}{|c|c|c|c|c|c|}\hline
         & \multicolumn{5}{c|}{\$L_2\$} \\\ \hline
-        & \$L=5\$   & \$O_2\$ & \$L=6\$    & \$O_2\$ & \$L=7\$  \\\ \hline"""
+        & \$L=5\$   & \$O_2\$ & \$L=6\$    & \$O_2\$ & \$L=7\$  \\\ \hline""")
 
 def order(r,color='black'):
    for i in range(0,len(r.l)-1):
      y0,y1 = r.l[i][1],r.l[i+1][1]
-     print '& {\color{%s}%.2e} & {\color{%s}%4.2f}' % (color, y0, color, log(y0/y1)/log(2.)),
-   print '& {\color{%s}%.2e}' % (color, r.l[i+1][1]), r'\\\'
+     print('& {\color{%s}%.2e} & {\color{%s}%4.2f}' % (color, y0, color, log(y0/y1)/log(2.)),)
+   print('& {\color{%s}%.2e}' % (color, r.l[i+1][1]), r'\\\')
 
-print 'Uniform',
+print('Uniform', end=' ')
 order(Curve('r0',1,2))
 order(Curve('r0.ref',1,2),'blue')
-print '\$r=1\$',
+print('\$r=1\$', end=' ')
 order(Curve('r1',1,2))
 order(Curve('r1.ref',1,2),'blue')
-print '\$r=2\$',
+print('\$r=2\$', end=' ')
 order(Curve('r2',1,2))
 order(Curve('r2.ref',1,2),'blue')
 
-print r"""\hline
+print(r"""\hline)
         & \multicolumn{5}{c|}{\$L_\infty\$} \\\ \hline
         & \$L=5\$   & \$O_\infty\$  & \$L=6\$   & \$O_\infty\$  & \$L=7\$ \\\ \hline"""
 
-print 'Uniform',
+print('Uniform', end=' ')
 order(Curve('r0',1,3))
 order(Curve('r0.ref',1,3),'blue')
-print '\$r=1\$',
+print('\$r=1\$', end=' ')
 order(Curve('r1',1,3))
 order(Curve('r1.ref',1,3),'blue')
-print '\$r=2\$',
+print('\$r=2\$', end=' ')
 order(Curve('r2',1,3))
 order(Curve('r2.ref',1,3),'blue')
 
-print r"\hline\end{tabular}"
+print(r"\hline\end{tabular}")
 EOF
 else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 for r in ['r0','r1','r2']:
diff --git a/test/planar.sh b/test/planar.sh
index 5cb55e1..a324b44 100755
--- a/test/planar.sh
+++ b/test/planar.sh
@@ -1 +1 @@
-python -u test.py planar
+python3 -u test.py planar
diff --git a/test/plate.sh b/test/plate.sh
index f51d3cb..ed6351e 100755
--- a/test/plate.sh
+++ b/test/plate.sh
@@ -1 +1 @@
-python -u test.py plate
+python3 -u test.py plate
diff --git a/test/plateau.sh b/test/plateau.sh
index 1090cf1..8e81dc9 100755
--- a/test/plateau.sh
+++ b/test/plateau.sh
@@ -1 +1 @@
-python -u test.py plateau
+python3 -u test.py plateau
diff --git a/test/poiseuille.sh b/test/poiseuille.sh
index 2f7a983..8486b65 100755
--- a/test/poiseuille.sh
+++ b/test/poiseuille.sh
@@ -1 +1 @@
-python -u test.py poiseuille
+python3 -u test.py poiseuille
diff --git a/test/poiseuille/poiseuille.sh b/test/poiseuille/poiseuille.sh
index d4872e0..380468a 100644
--- a/test/poiseuille/poiseuille.sh
+++ b/test/poiseuille/poiseuille.sh
@@ -31,7 +31,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
diff --git a/test/poiseuille/river/river.sh b/test/poiseuille/river/river.sh
index 16d2e9b..5de1c7b 100644
--- a/test/poiseuille/river/river.sh
+++ b/test/poiseuille/river/river.sh
@@ -28,7 +28,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,2) - Curve('error.ref',1,2)).max() > 1e-6:
diff --git a/test/poisson.sh b/test/poisson.sh
index 567c4fc..d035709 100755
--- a/test/poisson.sh
+++ b/test/poisson.sh
@@ -1 +1 @@
-python -u test.py poisson
+python3 -u test.py poisson
diff --git a/test/poisson/poisson.sh b/test/poisson/poisson.sh
index 280f5a7..a4fc80c 100644
--- a/test/poisson/poisson.sh
+++ b/test/poisson/poisson.sh
@@ -97,18 +97,18 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max() > 1e-8 or\
    (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
-    print (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max()
-    print (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max()
+    print((Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max())
+    print((Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max())
     exit(1)
 if (Curve('res-7-hypre',1,3) - Curve('res-7.ref',1,7)).max() > 1e-8 or\
    (Curve('error-hypre',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
-    print (Curve('res-7-hypre',1,3) - Curve('res-7.ref',1,7)).max()
-    print (Curve('error-hypre',1,4) - Curve('error.ref',1,4)).max()
+    print((Curve('res-7-hypre',1,3) - Curve('res-7.ref',1,7)).max())
+    print((Curve('error-hypre',1,4) - Curve('error.ref',1,4)).max())
     exit(1)
 EOF
 else
diff --git a/test/reynolds.sh b/test/reynolds.sh
index caf1bd8..54ce987 100755
--- a/test/reynolds.sh
+++ b/test/reynolds.sh
@@ -1 +1 @@
-python -u test.py reynolds
+python3 -u test.py reynolds
diff --git a/test/reynolds/reynolds.sh b/test/reynolds/reynolds.sh
index 1855984..056f79b 100644
--- a/test/reynolds/reynolds.sh
+++ b/test/reynolds/reynolds.sh
@@ -58,14 +58,14 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 for div in ['div5','div6','div7']:
   if (Curve(div,3,9) - Curve(div+'.ref',3,9)).max() > 0.01*Curve(div+'.ref',3,9).mean() or\
      (Curve(div,3,7) - Curve(div+'.ref',3,7)).max() > 0.01*Curve(div+'.ref',3,7).mean():
-    print (Curve(div,3,9) - Curve(div+'.ref',3,9)).max(), 0.01*Curve(div+'.ref',3,9).mean()
-    print (Curve(div,3,7) - Curve(div+'.ref',3,7)).max(), 0.01*Curve(div+'.ref',3,7).mean()
+    print((Curve(div,3,9) - Curve(div+'.ref',3,9)).max(), 0.01*Curve(div+'.ref',3,9).mean())
+    print((Curve(div,3,7) - Curve(div+'.ref',3,7)).max(), 0.01*Curve(div+'.ref',3,7).mean())
     exit(1)
 EOF
 else
diff --git a/test/reynolds/skew/skew.sh b/test/reynolds/skew/skew.sh
index ca37e43..117c96b 100644
--- a/test/reynolds/skew/skew.sh
+++ b/test/reynolds/skew/skew.sh
@@ -43,7 +43,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 for div in ['div5','div6','div7']:
diff --git a/test/reynolds/skewbox/skew.sh b/test/reynolds/skewbox/skew.sh
index d59ca31..fd1f4c0 100644
--- a/test/reynolds/skewbox/skew.sh
+++ b/test/reynolds/skewbox/skew.sh
@@ -33,13 +33,13 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 0.01*Curve('error.ref',1,4).mean() or\
    (Curve('error',1,5) - Curve('error.ref',1,5)).max() > 0.01*Curve('error.ref',1,5).mean():
-  print (Curve('error',1,4) - Curve('error.ref',1,4)).max(), 0.01*Curve('error.ref',1,4).mean()
-  print (Curve('error',1,5) - Curve('error.ref',1,5)).max(), 0.01*Curve('error.ref',1,5).mean()
+  print((Curve('error',1,4) - Curve('error.ref',1,4)).max(), 0.01*Curve('error.ref',1,4).mean())
+  print((Curve('error',1,5) - Curve('error.ref',1,5)).max(), 0.01*Curve('error.ref',1,5).mean())
   exit(1)
 EOF
 else
diff --git a/test/rossby.sh b/test/rossby.sh
index 5bbc154..0700e13 100755
--- a/test/rossby.sh
+++ b/test/rossby.sh
@@ -1 +1 @@
-python -u test.py rossby
+python3 -u test.py rossby
diff --git a/test/rossby/rossby.sh b/test/rossby/rossby.sh
index 5f2ffc7..ee93694 100644
--- a/test/rossby/rossby.sh
+++ b/test/rossby/rossby.sh
@@ -69,13 +69,13 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('eh-4',3,9) - Curve('eh-4.ref',3,9)).max() > 1e-5 or\
    (Curve('eh-5',3,9) - Curve('eh-5.ref',3,9)).max() > 1e-5:
-    print (Curve('eh-4',3,9) - Curve('eh-4.ref',3,9)).max()
-    print (Curve('eh-5',3,9) - Curve('eh-5.ref',3,9)).max()
+    print((Curve('eh-4',3,9) - Curve('eh-4.ref',3,9)).max())
+    print((Curve('eh-5',3,9) - Curve('eh-5.ref',3,9)).max())
     exit(1)
 EOF
 else
diff --git a/test/rotate.sh b/test/rotate.sh
index 0b5019b..ae389ea 100755
--- a/test/rotate.sh
+++ b/test/rotate.sh
@@ -1 +1 @@
-python -u test.py rotate
+python3 -u test.py rotate
diff --git a/test/sessile.sh b/test/sessile.sh
index 580eee2..f3f46c8 100755
--- a/test/sessile.sh
+++ b/test/sessile.sh
@@ -1 +1 @@
-python -u test.py sessile
+python3 -u test.py sessile
diff --git a/test/sessile/sessile.sh b/test/sessile/sessile.sh
index 87a9f6f..f4d4f39 100644
--- a/test/sessile/sessile.sh
+++ b/test/sessile/sessile.sh
@@ -78,11 +78,11 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error-6',1,2) - Curve('error-6.ref',1,2)).max() > 0.:
-    print (Curve('error-6',1,2) - Curve('error-6.ref',1,2)).max()
+    print((Curve('error-6',1,2) - Curve('error-6.ref',1,2)).max())
     exit(1)
 EOF
 else
diff --git a/test/shear.sh b/test/shear.sh
index 6cf6e5d..d5fb595 100755
--- a/test/shear.sh
+++ b/test/shear.sh
@@ -1 +1 @@
-python -u test.py shear
+python3 -u test.py shear
diff --git a/test/shear/concentration/concentration.sh b/test/shear/concentration/concentration.sh
index 723d3f0..6d35903 100644
--- a/test/shear/concentration/concentration.sh
+++ b/test/shear/concentration/concentration.sh
@@ -38,7 +38,7 @@ else
 fi
 
 for i in "" 1 2; do
-    if python <<EOF ; then :
+    if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('convergence$i',1,2) - Curve('convergence$i.ref',1,2)).max() > 0. or\
diff --git a/test/shear/shear.sh b/test/shear/shear.sh
index cbfd8a5..a63c177 100644
--- a/test/shear/shear.sh
+++ b/test/shear/shear.sh
@@ -11,7 +11,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('norms',3,5) - Curve('norms.ref',3,5)).max() > 0. or\
diff --git a/test/shock.sh b/test/shock.sh
index 54a0367..ec926ea 100755
--- a/test/shock.sh
+++ b/test/shock.sh
@@ -1 +1 @@
-python -u test.py shock
+python3 -u test.py shock
diff --git a/test/shock/layered/layered.sh b/test/shock/layered/layered.sh
index 4d40734..c9d7968 100644
--- a/test/shock/layered/layered.sh
+++ b/test/shock/layered/layered.sh
@@ -59,11 +59,11 @@ else
 fi
 fixbb u.eps
 
-if python <<EOF; then :
+if python3 <<EOF; then :
 from check import *
 from sys import *
 if (Curve('prof-8-15',1,2) - Curve('prof.ref',1,2)).max() > 1e-3:
-    print (Curve('prof-8-15',1,2) - Curve('prof.ref',1,2)).max()
+    print((Curve('prof-8-15',1,2) - Curve('prof.ref',1,2)).max())
     exit(1)
 EOF
 else
diff --git a/test/shock/shock.sh b/test/shock/shock.sh
index ee281ff..249ab04 100644
--- a/test/shock/shock.sh
+++ b/test/shock/shock.sh
@@ -39,11 +39,11 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('error',1,3) - Curve('error.ref',1,3)).max() > 1e-5:
-    print (Curve('error',1,3) - Curve('error.ref',1,3)).max()
+    print((Curve('error',1,3) - Curve('error.ref',1,3)).max())
     exit(1)
 EOF
 else
diff --git a/test/shore.sh b/test/shore.sh
index 721021d..450c6cd 100755
--- a/test/shore.sh
+++ b/test/shore.sh
@@ -1 +1 @@
-python -u test.py shore
+python3 -u test.py shore
diff --git a/test/shore/shore.sh b/test/shore/shore.sh
index 3a9104f..b247cf9 100644
--- a/test/shore/shore.sh
+++ b/test/shore/shore.sh
@@ -10,7 +10,7 @@ if test x$donotrun != xtrue; then
     done
 fi
 
-if python <<EOF > convergence; then :
+if python3 <<EOF > convergence; then :
 from check import *
 from sys import *
 
@@ -18,7 +18,7 @@ for i in range($levelmin,$levelmax + 1):
   ref = Curve('t220.csv',1,2)
   sol = Curve('sim-' + str(i) + '-220.txt',1,8)
   diff = ref - sol
-  print i,diff.norm1(),diff.normi()
+  print(i,diff.norm1(),diff.normi())
 
 EOF
 else
@@ -60,7 +60,7 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('convergence',1,2) - Curve('convergence.ref',1,2)).max() > 0. or\
@@ -69,4 +69,4 @@ if (Curve('convergence',1,2) - Curve('convergence.ref',1,2)).max() > 0. or\
 EOF
 else
    exit 1
-fi
\ No newline at end of file
+fi
diff --git a/test/source.sh b/test/source.sh
index 0a70443..eba45f2 100755
--- a/test/source.sh
+++ b/test/source.sh
@@ -1 +1 @@
-python -u test.py source
+python3 -u test.py source
diff --git a/test/source/source.sh b/test/source/source.sh
index 277d38f..6673ac9 100644
--- a/test/source/source.sh
+++ b/test/source/source.sh
@@ -48,13 +48,13 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-4 or\
    (Curve('error',1,3) - Curve('error.ref',1,3)).max() > 1e-4:
-    print (Curve('error',1,4) - Curve('error.ref',1,4)).max()
-    print (Curve('error',1,3) - Curve('error.ref',1,3)).max()
+    print((Curve('error',1,4) - Curve('error.ref',1,4)).max())
+    print((Curve('error',1,3) - Curve('error.ref',1,3)).max())
     exit(1)
 EOF
 else
diff --git a/test/spurious.sh b/test/spurious.sh
index b1eca4b..ccef1eb 100755
--- a/test/spurious.sh
+++ b/test/spurious.sh
@@ -1 +1 @@
-python -u test.py spurious
+python3 -u test.py spurious
diff --git a/test/spurious/spurious.sh b/test/spurious/spurious.sh
index 47ffa27..ffe92c2 100644
--- a/test/spurious/spurious.sh
+++ b/test/spurious/spurious.sh
@@ -70,7 +70,7 @@ for f in La-120-5 La-1200-5 La-12000-5; do
     fi
 done
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('convergence',1,3) - Curve('convergence.ref',1,3)).max() > 1e-6:
diff --git a/test/still.sh b/test/still.sh
index 936d328..2033f05 100755
--- a/test/still.sh
+++ b/test/still.sh
@@ -1 +1 @@
-python -u test.py still
+python3 -u test.py still
diff --git a/test/strouhal.sh b/test/strouhal.sh
index 4b0a36b..f559cc8 100755
--- a/test/strouhal.sh
+++ b/test/strouhal.sh
@@ -1 +1 @@
-python -u test.py strouhal
+python3 -u test.py strouhal
diff --git a/test/strouhal/strouhal.sh b/test/strouhal/strouhal.sh
index b08f553..84581a7 100644
--- a/test/strouhal/strouhal.sh
+++ b/test/strouhal/strouhal.sh
@@ -46,7 +46,7 @@ else
    exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('strouhal.res',1,2) - Curve('strouhal.ref',1,2)).max() > 0.01 :
diff --git a/test/swirl.sh b/test/swirl.sh
index 6f8bea4..d7db147 100755
--- a/test/swirl.sh
+++ b/test/swirl.sh
@@ -1 +1 @@
-python -u test.py swirl
+python3 -u test.py swirl
diff --git a/test/swirl/swirl.gfs b/test/swirl/swirl.gfs
index 4f0f59e..75b41a4 100644
--- a/test/swirl/swirl.gfs
+++ b/test/swirl/swirl.gfs
@@ -78,13 +78,13 @@ EOF
 	    exit $GFS_STOP;
 	fi
 
-	if python <<EOF ; then :
+	if python3 <<EOF ; then :
 from check import *
 from sys import *
 if (Curve('nu',1,2) - Curve('analytical',1,2)).normi() > 8e-3 or \
    (Curve('nu',1,3) - Curve('analytical',1,3)).normi() > 8e-3 :
-    print (Curve('nu',1,2) - Curve('analytical',1,2)).normi()
-    print (Curve('nu',1,3) - Curve('analytical',1,3)).normi()
+    print((Curve('nu',1,2) - Curve('analytical',1,2)).normi())
+    print((Curve('nu',1,3) - Curve('analytical',1,3)).normi())
     exit(1)
 EOF
 	else
diff --git a/test/terrain.sh b/test/terrain.sh
index 1b7ae30..6837a7f 100755
--- a/test/terrain.sh
+++ b/test/terrain.sh
@@ -1 +1 @@
-python -u test.py terrain
+python3 -u test.py terrain
diff --git a/test/terrain/terrain.sh b/test/terrain/terrain.sh
index 6bca2fc..3e28925 100644
--- a/test/terrain/terrain.sh
+++ b/test/terrain/terrain.sh
@@ -60,7 +60,7 @@ else
     exit 1
 fi
 
-if python <<EOF ; then :
+if python3 <<EOF ; then :
 from check import *
 from sys import *
 c = Curve()
@@ -68,10 +68,10 @@ if (Curve('error-t',1,3) - Curve('error-t.ref',1,3)).max() > 0. or\
    (Curve('error-t',1,4) - Curve('error-t.ref',1,4)).max() > 0. or\
    (Curve('error-h',1,3) - Curve('error-h.ref',1,3)).max() > 0. or\
    (Curve('error-h',1,4) - Curve('error-h.ref',1,4)).max() > 0.:
-    print (Curve('error-t',1,3) - Curve('error-t.ref',1,3)).max()
-    print (Curve('error-t',1,4) - Curve('error-t.ref',1,4)).max()
-    print (Curve('error-h',1,3) - Curve('error-h.ref',1,3)).max()
-    print (Curve('error-h',1,4) - Curve('error-h.ref',1,4)).max() 
+    print((Curve('error-t',1,3) - Curve('error-t.ref',1,3)).max())
+    print((Curve('error-t',1,4) - Curve('error-t.ref',1,4)).max())
+    print((Curve('error-h',1,3) - Curve('error-h.ref',1,3)).max())
+    print((Curve('error-h',1,4) - Curve('error-h.ref',1,4)).max() )
     exit(1)
 EOF
 else
diff --git a/test/test.py b/test/test.py
index a2059ff..9efa297 100644
--- a/test/test.py
+++ b/test/test.py
@@ -1,5 +1,5 @@
 import sys
-import commands
+import subprocess
 import os
 import os.path
 sys.path.append("../doc/examples")
@@ -15,14 +15,14 @@ for start in sys.argv[1:]:
             test = gfs2tex.Example(root)
             status,msg = test.run(env)
             if status != None:
-                print "FAIL:",root
+                print("FAIL:",root)
                 if len(msg) > 0:
-                    print " ".join(msg)
-                print >>open(test.path + "/status",'w'), "{\color{Red}FAIL}:"
+                    print(" ".join(msg))
+                print("{\color{Red}FAIL}:", file=open(test.path + "/status",'w'))
                 failed += 1
             else:
-                print "PASS:",root
-                print >>open(test.path + "/status",'w'), "{\color{OliveGreen}PASS}:"
+                print("PASS:",root)
+                print("{\color{OliveGreen}PASS}:", file=open(test.path + "/status",'w'))
             n += 1
 
 if failed:
@@ -30,9 +30,9 @@ if failed:
 else:
     msg = "All " + repr(n) + " tests passed"
 
-print len(msg)*"="
-print msg
-print len(msg)*"="
+print(len(msg)*"=")
+print(msg)
+print(len(msg)*"=")
 
 if failed:
     sys.exit(1)
diff --git a/test/wannier.sh b/test/wannier.sh
index 8340b04..bb87d7d 100755
--- a/test/wannier.sh
+++ b/test/wannier.sh
@@ -1 +1 @@
-python -u test.py wannier
+python3 -u test.py wannier
diff --git a/test/wannier/bipolar/bipolar.sh b/test/wannier/bipolar/bipolar.sh
index 9a29a66..f44b3be 100644
--- a/test/wannier/bipolar/bipolar.sh
+++ b/test/wannier/bipolar/bipolar.sh
@@ -48,7 +48,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
diff --git a/test/wannier/wannier.sh b/test/wannier/wannier.sh
index 496b278..e5dc1d6 100644
--- a/test/wannier/wannier.sh
+++ b/test/wannier/wannier.sh
@@ -34,7 +34,7 @@ else
     exit 1
 fi
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if (Curve('error',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
diff --git a/test/waves.sh b/test/waves.sh
index a518a7a..dc0dec4 100755
--- a/test/waves.sh
+++ b/test/waves.sh
@@ -1 +1 @@
-python -u test.py waves
+python3 -u test.py waves
diff --git a/test/waves/waves.sh b/test/waves/waves.sh
index e537c6c..3a521d3 100644
--- a/test/waves/waves.sh
+++ b/test/waves/waves.sh
@@ -29,7 +29,7 @@ awk 'BEGIN {
   print "\\end{tabular}"
 }' < correlation > correlation.tex
 
-if cat <<EOF | python ; then :
+if cat <<EOF | python3 ; then :
 from check import *
 from sys import *
 if Curve('correlation',1,3).max() > 10.:
