From 654ffc91eb1621d038f9abe4f585e9952818177f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 14 May 2024 13:00:29 -0600 Subject: [PATCH] Python3 requires parentheses around arguments of 'print'. Python2 doesn't care one way or the other, so the compatible thing to do is to have parentheses. --- SLcode_py/SL_equation_elastic.py | 20 ++++++++++---------- SLcode_py/pyspharm.py | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/SLcode_py/SL_equation_elastic.py b/SLcode_py/SL_equation_elastic.py index b02aedf..1db7e14 100644 --- a/SLcode_py/SL_equation_elastic.py +++ b/SLcode_py/SL_equation_elastic.py @@ -182,8 +182,8 @@ def love_lm(num, group='m'): """ num = num[:maxdeg] h = np.hstack(( 0, num.squeeze() )) - h_lm = []; - print group + h_lm = [] + print (group) if group == 'l': # This is the standard for Jerry's code for l in range(maxdeg+1): @@ -295,13 +295,13 @@ def calc_rot(L_in, _k, _k_tide, group='l'): L20 = L_in[3] L21 = L_in[4] L22 = L_in[5] - print L22 + print (L22) elif group == 'm': - print "WARN: hard-coded max l,m; will break!" + print ("WARN: hard-coded max l,m; will break!") L20 = L_in[2] L21 = L_in[maxdeg+2] L22 = L_in[2*maxdeg + 1] - print L22 + print (L22) k_L = _k[1] # This has 256 values k_T = _k_tide[1] # This has 256 values @@ -355,7 +355,7 @@ def calc_rot(L_in, _k, _k_tide, group='l'): # Iteration criterion epsilon while (k < k_max) and (chi >= epsilon): - #print chi + #print (chi) # expand ocean function into spherical harmonics # in m-first ordering @@ -467,14 +467,14 @@ def calc_rot(L_in, _k, _k_tide, group='l'): k += 1 if chi < epsilon: - print 'Converged after iteration', k, 'Chi was', chi + print ('Converged after iteration', k, 'Chi was', chi) else: - print 'Did not yet converge.' - print 'Finished iteration', k, '; Chi was', chi + print ('Did not yet converge.') + print ('Finished iteration', k, '; Chi was', chi) end_time = time.time() -print "Time elapsed in k loop", end_time - start_time +print ("Time elapsed in k loop", end_time - start_time) # calculate the scaling to normalize the fingerprint (it's normalized to be # one on average, when averaged over the final ocean basin). diff --git a/SLcode_py/pyspharm.py b/SLcode_py/pyspharm.py index f07c8b5..5096a05 100644 --- a/SLcode_py/pyspharm.py +++ b/SLcode_py/pyspharm.py @@ -192,7 +192,7 @@ def specdata(self): vrtg = x.spectogrd(vrtspec) ug,vg = x.getuv(vrtspec,divspec) phig = x.spectogrd(phispec) - print 't=%6.2f hours: min/max %6.2f, %6.2f' % (t/3600.,vg.min(), vg.max()) + print ('t=%6.2f hours: min/max %6.2f, %6.2f' % (t/3600.,vg.min(), vg.max())) # compute tendencies. tmpg1 = ug*(vrtg+f); tmpg2 = vg*(vrtg+f) ddivdtspec[:,nnew], dvrtdtspec[:,nnew] = x.getvrtdivspec(tmpg1,tmpg2) @@ -233,13 +233,13 @@ def specdata(self): nnew = nold; nnow = nsav1; nold = nsav2 time2 = time.clock() - print 'CPU time = ',time2-time1 + print ('CPU time = ',time2-time1) # make a orthographic plot of potential vorticity. m = Basemap(projection='ortho',lat_0=45,lon_0=0) # dimensionless PV pvg = (0.5*hbar*grav/omega)*(vrtg+f)/phig - print 'max/min PV',pvg.min(), pvg.max() + print ('max/min PV',pvg.min(), pvg.max()) lons1d = (180./np.pi)*x.lons; lats1d = (180./np.pi)*x.lats pvg,lons1d = addcyclic(pvg,lons1d) lons, lats = np.meshgrid(lons1d,lats1d)