Index: /issm/trunk-jpl/scripts/BinRead.py
===================================================================
--- /issm/trunk-jpl/scripts/BinRead.py	(revision 24211)
+++ /issm/trunk-jpl/scripts/BinRead.py	(revision 24212)
@@ -1,209 +1,210 @@
-#! /usr/bin/env python
-
-import os
+#! / usr / bin / env python
+import numpy as np
+from os import environ, path
 import sys
-import numpy
-import math
 import struct
-import argparse
-
-def BinRead(filin,filout='',verbose=0): #{{{
-
-	print "reading binary file."
-	f=open(filin,'rb')
-
-	if filout:
-		sys.stdout=open(filout,'w')
-
-	while True:
-		try:
-			#Step 1: read size of record name
-			recordnamesize=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-		except struct.error as e:
-			print "probable EOF: %s" % e
-			break
-
-		print "============================================================================"
-		if verbose>2:
-			print "\nrecordnamesize = \"%d\"" % (recordnamesize)
-		recordname=struct.unpack('%ds' % recordnamesize,f.read(recordnamesize))[0]
-		print "field: %s" % recordname
-
-		#Step 2: read the data itself.
-		#first read length of record
-		reclen=struct.unpack('q',f.read(struct.calcsize('q')))[0]
-		if verbose>1:
-			print "reclen = %d" % reclen
-
-		#read data code: 
-		code=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-		#print "code = %d (%s)" % (code,CodeToFormat(code))
-		print "Format = %s" % CodeToFormat(code)
-
-		if   code == FormatToCode('Boolean'):
-#			bval=struct.unpack('b',f.read(reclen-struct.calcsize('i')))[0]
-			bval=struct.unpack('i',f.read(reclen-struct.calcsize('i')))[0]
-			print "value = %d" % bval
-
-		elif code == FormatToCode('Integer'):
-			ival=struct.unpack('i',f.read(reclen-struct.calcsize('i')))[0]
-			print "value = %d" % ival
-
-		elif code == FormatToCode('Double'):
-			dval=struct.unpack('d',f.read(reclen-struct.calcsize('i')))[0]
-			print "value = %f" % dval
-
-		elif code == FormatToCode('String'):
-			strlen=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			if verbose>1:
-				print "strlen = %d" % strlen
-			sval=struct.unpack('%ds' % strlen,f.read(strlen))[0]
-			print "value = '%s'" % sval
-
-		elif code == FormatToCode('BooleanMat'):
-			#read matrix type: 
-			mattype=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			print "mattype = %d" % mattype
-
-			#now read matrix
-			s=[0,0]
-			s[0]=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			s[1]=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			print "size = [%dx%d]" % (s[0],s[1])
-			data=numpy.zeros((s[0],s[1]))
-			for i in xrange(s[0]):
-				for j in xrange(s[1]):
-					data[i][j]=struct.unpack('d',f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
-					if verbose>2: print "data[%d,%d] = %f" % (i,j,data[i][j])
-
-		elif code == FormatToCode('IntMat'):
-			#read matrix type: 
-			mattype=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			print "mattype = %d" % mattype
-
-			#now read matrix
-			s=[0,0]
-			s[0]=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			s[1]=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			print "size = [%dx%d]" % (s[0],s[1])
-			data=numpy.zeros((s[0],s[1]))
-			for i in xrange(s[0]):
-				for j in xrange(s[1]):
-					data[i][j]=struct.unpack('d',f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
-					if verbose>2: print "data[%d,%d] = %f" % (i,j,data[i][j])
-
-		elif code == FormatToCode('DoubleMat'):
-			#read matrix type: 
-			mattype=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			print "mattype = %d" % mattype
-
-			#now read matrix
-			s=[0,0]
-			s[0]=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			s[1]=struct.unpack('i',f.read(struct.calcsize('i')))[0]
-			print "size = [%dx%d]" % (s[0],s[1])
-			data=numpy.zeros((s[0],s[1]))
-			for i in xrange(s[0]):
-				for j in xrange(s[1]):
-					data[i][j]=struct.unpack('d',f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
-					if verbose>2: print "data[%d,%d] = %f" % (i,j,data[i][j])
-
-		elif code == FormatToCode('MatArray'):
-			f.seek(reclen-4,1)
-			print "skipping %d bytes for code %d." % (reclen-4, code)
-
-		elif code == FormatToCode('StringArray'):
-			f.seek(reclen-4,1)
-			print "skipping %d bytes for code %d." % (reclen-4, code)
-
-		elif code == FormatToCode('CompressedMat'):
-			print "still need to implement reading for code %d." % code
-
-		else:
-			raise TypeError('BinRead error message: data type: %d not supported yet! (%s)' % (code, recordname))
-
-	f.close()
+from argparse import ArgumentParser
+
+
+def BinRead(filin, filout='', verbose=0):  #{{{
+
+    print("reading binary file.")
+    f = open(filin, 'rb')
+
+    if filout:
+        sys.stdout = open(filout, 'w')
+
+    while True:
+        try:
+            #Step 1: read size of record name
+            recordnamesize = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+        except struct.error as e:
+            print("probable EOF: {}".format(e))
+            break
+
+        print("============================================================================ ")
+        if verbose > 2:
+            print("\n recordnamesize = {}".format(recordnamesize))
+        recordname = struct.unpack('{}s'.format(recordnamesize), f.read(recordnamesize))[0]
+        print("field: {}".format(recordname))
+
+        #Step 2: read the data itself.
+        #first read length of record
+        #reclen = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+        reclen = struct.unpack('q', f.read(struct.calcsize('q')))[0]
+        if verbose > 1:
+            print("reclen = {}".format(reclen))
+
+        #read data code:
+        code = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+        print("Format = {} (code {})".format(CodeToFormat(code), code))
+
+        if code == FormatToCode('Boolean'):
+            bval = struct.unpack('i', f.read(reclen - struct.calcsize('i')))[0]
+            print("value = {}".format(bval))
+
+        elif code == FormatToCode('Integer'):
+            ival = struct.unpack('i', f.read(reclen - struct.calcsize('i')))[0]
+            print("value = {}".format(ival))
+
+        elif code == FormatToCode('Double'):
+            dval = struct.unpack('d', f.read(reclen - struct.calcsize('i')))[0]
+            print("value = {}".format(dval))
+
+        elif code == FormatToCode('String'):
+            strlen = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            if verbose > 1:
+                print("strlen = {}".format(strlen))
+            sval = struct.unpack('{}s'.format(strlen), f.read(strlen))[0]
+            print("value = '{}'".format(sval))
+
+        elif code == FormatToCode('BooleanMat'):
+            #read matrix type:
+            mattype = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            print("mattype = {}".format(mattype))
+
+            #now read matrix
+            s = [0, 0]
+            s[0] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            print("size = [{}x{}]".format(s[0], s[1]))
+            data = np.zeros((s[0], s[1]))
+            for i in range(s[0]):
+                for j in range(s[1]):
+                    data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
+                    if verbose > 2:
+                        print("data[{}, {}] = {}".format(i, j, data[i][j]))
+
+        elif code == FormatToCode('IntMat'):
+            #read matrix type:
+            mattype = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            print("mattype = {}".format(mattype))
+
+            #now read matrix
+            s = [0, 0]
+            s[0] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            print("size = [{}x{}]".format(s[0], s[1]))
+            data = np.zeros((s[0], s[1]))
+            for i in range(s[0]):
+                for j in range(s[1]):
+                    data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
+                    if verbose > 2:
+                        print("data[{}, {}] = {}".format(i, j, data[i][j]))
+
+        elif code == FormatToCode('DoubleMat'):
+            #read matrix type:
+            mattype = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            print("mattype = {}".format(mattype))
+
+            #now read matrix
+            s = [0, 0]
+            s[0] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
+            print("size = [{}x{}]".format(s[0], s[1]))
+            data = np.zeros((s[0], s[1]))
+            for i in range(s[0]):
+                for j in range(s[1]):
+                    data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
+                    if verbose > 2:
+                        print("data[{}, {}] = {}".format(i, j, data[i][j]))
+
+        elif code == FormatToCode('MatArray'):
+            f.seek(reclen - 4, 1)
+            print("skipping {} bytes for code {}.".format(code, reclen - 4))
+        elif code == FormatToCode('StringArray'):
+            f.seek(reclen - 4, 1)
+            print("skipping {} bytes for code {}.".format(code, reclen - 4))
+
+        else:
+            raise TypeError('BinRead error message: data type: {} not supported yet! ({})'.format(code, recordname))
+
+    f.close()
 #}}}
-def FormatToCode(format): # {{{
-	"""
-	This routine takes the format string, and hardcodes it into an integer, which 
-	is passed along the record, in order to identify the nature of the dataset being 
-	sent.
-	"""
-	if format=='Boolean':
-		code=1
-	elif format=='Integer':
-		code=2
-	elif format=='Double':
-		code=3
-	elif format=='String':
-		code=4
-	elif format=='BooleanMat':
-		code=5
-	elif format=='IntMat':
-		code=6
-	elif format=='DoubleMat':
-		code=7
-	elif format=='MatArray':
-		code=8
-	elif format=='StringArray':
-		code=9
-	elif format=='CompressedMat':
-		code=10
-	else:
-		raise InputError('FormatToCode error message: data type %s not supported yet!' % format)
-
-	return code
+
+
+def FormatToCode(format):  # {{{
+    """
+    This routine takes the format string, and hardcodes it into an integer, which
+    is passed along the record, in order to identify the nature of the dataset being
+    sent.
+    """
+
+    if format == 'Boolean':
+        code = 1
+    elif format == 'Integer':
+        code = 2
+    elif format == 'Double':
+        code = 3
+    elif format == 'String':
+        code = 4
+    elif format == 'BooleanMat':
+        code = 5
+    elif format == 'IntMat':
+        code = 6
+    elif format == 'DoubleMat':
+        code = 7
+    elif format == 'MatArray':
+        code = 8
+    elif format == 'StringArray':
+        code = 9
+    else:
+        raise IOError('FormatToCode error message: data type not supported yet!')
+
+    return code
 # }}}
-def CodeToFormat(code): # {{{
-	"""
-	This routine takes the format string, and hardcodes it into an integer, which 
-	is passed along the record, in order to identify the nature of the dataset being 
-	sent.
-	"""
-	if code==1:
-		format='Boolean'
-	elif code==2:
-		format='Integer'
-	elif code==3:
-		format='Double'
-	elif code==4:
-		format='String'
-	elif code==5:
-		format='BooleanMat'
-	elif code==6:
-		format='IntMat'
-	elif code==7:
-		format='DoubleMat'
-	elif code==8:
-		format='MatArray'
-	elif code==9:
-		format='StringArray'
-	elif code==10:
-		format='CompressedMat'
-	else:
-		raise TypeError('CodeToFormat error message: code %d not supported yet!' % code)
-
-	return format
+
+
+def CodeToFormat(code):  # {{{
+    """
+    This routine takes the format string, and hardcodes it into an integer, which
+    is passed along the record, in order to identify the nature of the dataset being
+    sent.
+    """
+
+    if code == 1:
+        format = 'Boolean'
+    elif code == 2:
+        format = 'Integer'
+    elif code == 3:
+        format = 'Double'
+    elif code == 4:
+        format = 'String'
+    elif code == 5:
+        format = 'BooleanMat'
+    elif code == 6:
+        format = 'IntMat'
+    elif code == 7:
+        format = 'DoubleMat'
+    elif code == 8:
+        format = 'MatArray'
+    elif code == 9:
+        format = 'StringArray'
+    else:
+        raise TypeError('FormatToCode error message: code {} not supported yet!'.format(code))
+
+    return format
 # }}}
 
-if __name__ == '__main__': #{{{
-	if 'PYTHONSTARTUP' in os.environ:
-		PYTHONSTARTUP=os.environ['PYTHONSTARTUP']
-		print 'PYTHONSTARTUP =',PYTHONSTARTUP
-		if os.path.exists(PYTHONSTARTUP):
-			try:
-				execfile(PYTHONSTARTUP)
-			except Exception as e:
-				print "PYTHONSTARTUP error: ",e
-		else:
-			print "PYTHONSTARTUP file '%s' does not exist." % PYTHONSTARTUP
-
-	parser = argparse.ArgumentParser(description='BinRead - function to read binary input file.')
-	parser.add_argument('-f','--filin', help='name of binary input file', default='')
-	parser.add_argument('-o','--filout', help='optional name of text output file', default='')
-	parser.add_argument('-v','--verbose', help='optional level of output', default=0)
-	args = parser.parse_args()
-
-	BinRead(args.filin, args.filout,args.verbose)
+
+if __name__ == '__main__':  #{{{
+    if 'PYTHONSTARTUP' in environ:
+        PYTHONSTARTUP = environ['PYTHONSTARTUP']
+        print('PYTHONSTARTUP = {}'.format(PYTHONSTARTUP))
+        if path.exists(PYTHONSTARTUP):
+            try:
+                exec(compile(open(PYTHONSTARTUP).read(), PYTHONSTARTUP, 'exec'), globals())
+
+            except Exception as e:
+                print("PYTHONSTARTUP error: ", e)
+        else:
+            print("PYTHONSTARTUP file '{}' does not exist.".format(PYTHONSTARTUP))
+
+    parser = ArgumentParser(description='BinRead - function to read binary input file.')
+    parser.add_argument(' -f', ' --filin', help='name of binary input file', default='')
+    parser.add_argument(' -o', ' --filout', help='optional name of text output file', default='')
+    parser.add_argument(' -v', ' --verbose', help='optional level of output', default=0)
+    args = parser.parse_args()
+
+    BinRead(args.filin, args.filout, args.verbose)
 #}}}
Index: /issm/trunk-jpl/scripts/DownloadExternalPackage.py
===================================================================
--- /issm/trunk-jpl/scripts/DownloadExternalPackage.py	(revision 24211)
+++ /issm/trunk-jpl/scripts/DownloadExternalPackage.py	(revision 24212)
@@ -1,37 +1,35 @@
-#!/usr/bin/env python
-# -*- coding: ISO-8859-1 -*-
+#! / usr / bin / env python
+# - * - coding: ISO - 8859 - 1 - * -
 
-import os,sys
+import os
+import sys
 import urllib
 
 #Check inputs
-if(len(sys.argv)!=3): raise NameError('usage: ./DownloadExternalPackage.py URL localfile')
+if(len(sys.argv) != 3):
+    raise NameError('usage: . / DownloadExternalPackage.py URL localfile')
 
-url=sys.argv[1];
-localFile=sys.argv[2]
+url = sys.argv[1]
+localFile = sys.argv[2]
 
 #Remove file if it already exists
 if os.path.exists(localFile):
-	print "File "+ localFile +" already exists and will not be downloaded..."
-	sys.exit()
+    print("File " + localFile + " already exists and will not be downloaded...")
+    sys.exit()
 
 #Try to download from url
-httpfail=-1
+httpfail = -1
 try:
-	print "Fetching %s" % localFile
-	urllib.urlretrieve(url,localFile)
-	httpfail=0
-except Exception, e:
-	httpfail=1
-
-#Error message in case it failed
-if (httpfail):
-	failureMessage = '''
-===========================================================================
-Unable to download package %s from: %s
-* If URL specified manually - perhaps there is a typo?
-* If your network is disconnected - please reconnect 
-* Alternatively, you can download the above URL manually
-===========================================================================
-''' % (localFile,url)
-	raise RuntimeError(failureMessage)
+    print("Fetching %s" % localFile)
+    urllib.request(url, localFile)
+    httpfail = 0
+except urllib.error.URLError as e:
+    failureMessage = '''
+   ===========================================================================
+    Unable to download package {} from: {} due to {}
+    * If URL specified manually - perhaps there is a typo?
+    * If your network is disconnected - please reconnect
+    * Alternatively, you can download the above URL manually
+   ===========================================================================
+    '''.format(localFile, url, e)
+    print(failureMessage)
Index: /issm/trunk-jpl/scripts/cloc2html.py
===================================================================
--- /issm/trunk-jpl/scripts/cloc2html.py	(revision 24211)
+++ /issm/trunk-jpl/scripts/cloc2html.py	(revision 24212)
@@ -1,83 +1,105 @@
-#!/usr/bin/env python
-# -*- coding: ISO-8859-1 -*-
-#inspired from http://qwiki.stanford.edu/images/d/df/Latex2qwiki.txt
-import sys, re, os
+#! / usr / bin / env python
+# - * - coding: ISO - 8859 - 1 - * -
+#inspired from http: / / qwiki.stanford.edu / images / d / df / Latex2qwiki.txt
+import re
+import os
 
-ISSM_DIR=os.getenv('ISSM_DIR');
-if(not ISSM_DIR): raise NameError('ISSM_DIR undefined')
+ISSM_DIR = os.getenv('ISSM_DIR')
+if(not ISSM_DIR):
+    raise NameError('ISSM_DIR undefined')
 
-infile  = open('temp','r')
-outfile = open('temp.html','w')
-file_text  = infile.readlines()
+infile = open('temp', 'r')
+outfile = open('temp.html', 'w')
+file_text = infile.readlines()
 
 #write header
-outfile.write('<table width="600px" rules=none border=0 bordercolor="#000000" cellpadding="3" align="center" style="border-collapse:collapse;">\n')
-style_r='style="text-align:right;"'
-style_c='style="text-align:center;"'
-style_l='style="text-align:left;"'
-color = ' bgcolor=#7AA9DD ' #dark blue
-color1 = ' bgcolor=#C6E2FF ' #light blue
-color2 = ' bgcolor=#FFFFFF ' #white
+outfile.write(' < table width = "600px" rules = none border = 0 bordercolor = "#000000" cellpadding = "3" align = "center" style = "border - collapse:collapse;" > \n')
+style_r = 'style="text - align:right;"'
+style_c = 'style="text - align:center;"'
+style_l = 'style="text - align:left;"'
+color = ' bgcolor=#7AA9DD '  #dark blue
+color1 = ' bgcolor=#C6E2FF '  #light blue
+color2 = ' bgcolor=#FFFFFF '  #white
 
-count = 0 
+count = 0
 toggle = 0
 for i in range(len(file_text)):
 
-	#Get current lines except if first line
-	if(i==0): continue
-	line = file_text[i]
+    #Get current lines except if first line
+    if(i == 0):
+        continue
+    line = file_text[i]
 
-	pattern=r"----------------"
-	if (re.search(pattern,line)):
-		count+=1
-		continue
+    pattern = r"----------------"
+    if (re.search(pattern, line)):
+        count += 1
+        continue
 
-	if(count==1):
-		mystr = '<tr>\n'
-		column = 1
-		for i in line.split():
-			if(column==1): mystr += '<th '+color+style_l+'>'+i+'</th>'; column+=1
-			else:          mystr += '<th '+color+style_r+'>'+i+'</th>'
-		mystr += '<th '+color+style_r+'>Total</th>\n</th>\n'
-	elif(count==2):
-		total  = 0
-		column = 1
-		if(toggle): mystr = '<tr>\n<th '+color1+style_l+'>'
-		else:       mystr = '<tr>\n<th '+color2+style_l+'>'
-		for i in line.split():
-			if(not i.isdigit() or (i.isdigit and int(i)==77)):
-				mystr += ' '+i+' '
-			else:
-				if(column==1): mystr += '</th>'
-				if(column>=2): total += int(i)
-				if(toggle): mystr += '<td '+color1+style_r+'>'+i+'</td>'
-				else:       mystr += '<td '+color2+style_r+'>'+i+'</td>'
-				column += 1
-		if(toggle): mystr += '<td '+color1+style_r+'>'+str(total)+'</td>\n</tr>\n'
-		else:       mystr += '<td '+color2+style_r+'>'+str(total)+'</td>\n</tr>\n'
-		toggle = 1 - toggle
-	elif(count==3):
-		total  = 0
-		column = 1
-		if(toggle): mystr = '<tr>\n<th '+color1+style_l+'>'
-		else:       mystr = '<tr>\n<th '+color2+style_l+'>'
-		for i in line.split():
-			if(not i.isdigit()):
-				mystr += ' '+i+' '
-			else:
-				if(column==1): mystr += '</th>'
-				if(column>=2): total += int(i)
-				if(toggle): mystr += '<td '+color1+style_r+'>'+i+'</td>'
-				else:       mystr += '<td '+color2+style_r+'>'+i+'</td>'
-				column += 1
-		if(toggle): mystr += '<td '+color1+style_r+'>'+str(total)+'</td>\n</tr>\n'
-		else:       mystr += '<td '+color2+style_r+'>'+str(total)+'</td>\n</tr>\n'
-	else:
-		continue
+    if(count == 1):
+        mystr = ' < tr > \n'
+        column = 1
+        for i in line.split():
+            if(column == 1):
+                mystr += '<th ' + color + style_l + '>' + i + '</th>'
+                column += 1
+            else:
+                mystr += '<th ' + color + style_r + '>' + i + '</th>'
+        mystr += '<th ' + color + style_r + '>Total</th>\n</th>\n'
+    elif(count == 2):
+        total = 0
+        column = 1
+        if(toggle):
+            mystr = '<tr>\n<th ' + color1 + style_l + '>'
+        else:
+            mystr = '<tr>\n<th ' + color2 + style_l + '>'
+        for i in line.split():
+            if(not i.isdigit() or (i.isdigit and int(i) == 77)):
+                mystr += ' ' + i + ' '
+            else:
+                if(column == 1):
+                    mystr += '</th>'
+                if(column >= 2):
+                    total += int(i)
+                if(toggle):
+                    mystr += '<td ' + color1 + style_r + '>' + i + '</td>'
+                else:
+                    mystr += '<td ' + color2 + style_r + '>' + i + '</td>'
+                column += 1
+        if(toggle):
+            mystr += '<td ' + color1 + style_r + '>' + str(total) + '</td>\n</tr>\n'
+        else:
+            mystr += '<td ' + color2 + style_r + '>' + str(total) + '</td>\n</tr>\n'
+        toggle = 1 - toggle
+    elif(count == 3):
+        total = 0
+        column = 1
+        if(toggle):
+            mystr = '<tr>\n<th ' + color1 + style_l + '>'
+        else:
+            mystr = '<tr>\n<th ' + color2 + style_l + '>'
+        for i in line.split():
+            if(not i.isdigit()):
+                mystr += ' ' + i + ' '
+            else:
+                if(column == 1):
+                    mystr += '</th>'
+                if(column >= 2):
+                    total += int(i)
+                if(toggle):
+                    mystr += '<td ' + color1 + style_r + '>' + i + '</td>'
+                else:
+                    mystr += '<td ' + color2 + style_r + '>' + i + '</td>'
+                column += 1
+        if(toggle):
+            mystr += '<td ' + color1 + style_r + '>' + str(total) + '</td>\n</tr>\n'
+        else:
+            mystr += '<td ' + color2 + style_r + '>' + str(total) + '</td>\n</tr>\n'
+    else:
+        continue
 
-	outfile.write(mystr)
+    outfile.write(mystr)
 
 #write header
-outfile.write('</table>\n')
+outfile.write(' </table>\n')
 
 #close all files
Index: /issm/trunk-jpl/scripts/convertmatlabclasses.py
===================================================================
--- /issm/trunk-jpl/scripts/convertmatlabclasses.py	(revision 24211)
+++ /issm/trunk-jpl/scripts/convertmatlabclasses.py	(revision 24212)
@@ -1,14 +1,19 @@
-#!/usr/bin/env python
-# -*- coding: ISO-8859-1 -*-
-import sys, re, os, shutil
+#! / usr / bin / env python
+# - * - coding: ISO - 8859 - 1 - * -
+import sys
+import re
+import os
+import shutil
 
 #get names of all directories to process
-ISSM_DIR=os.getenv('ISSM_DIR');
-if(not ISSM_DIR): raise NameError('ISSM_DIR undefined')
+ISSM_DIR = os.getenv('ISSM_DIR')
+if(not ISSM_DIR):
+    raise NameError('ISSM_DIR undefined')
 newclassesdir = ISSM_DIR + '/src/m/classes/'
 oldclassesdir = ISSM_DIR + '/src/m/oldclasses/'
 
 #make new directory
-if(os.path.exists(oldclassesdir)):shutil.rmtree(oldclassesdir)
+if(os.path.exists(oldclassesdir)):
+    shutil.rmtree(oldclassesdir)
 os.mkdir(oldclassesdir)
 
@@ -16,10 +21,10 @@
 #{{{
 subsasgntext = r'''
-function obj = subsasgn(obj,index,val)
-obj=builtin('subsasgn',obj,index,val);
+function obj = subsasgn(obj, index, val)
+obj = builtin('subsasgn', obj, index, val)
 '''
 subsreftext = r'''
-function obj = subsref(obj,index)
-obj=builtin('subsref',obj,index);
+function obj = subsref(obj, index)
+obj = builtin('subsref', obj, index)
 '''
 #}}}
@@ -28,126 +33,144 @@
 files = os.listdir(newclassesdir)
 for filename in files:
-	newpath = newclassesdir + filename
-	oldpath = oldclassesdir + filename
-	if(filename==".svn"):         continue
-	if(filename.endswith(".m")):  shutil.copy(newpath,oldpath)
-	if(filename.startswith("@")): shutil.copytree(newpath,oldpath)
-	if(filename=="clusters"):
-		files2 = os.listdir(newpath)
-		for filename2 in files2:
-			if(filename2==".svn"): continue
-			newpath = newclassesdir + filename +'/'+ filename2
-			oldpath = oldclassesdir + filename2
-			shutil.copy(newpath,oldpath)
-	if(filename=="model"):
-		shutil.copy(newpath+'/model.m'     ,oldclassesdir+'model.m');
-	if(filename=="qmu"):
-		shutil.copytree(newpath+'/@dakota_method',oldclassesdir+'/@dakota_method')
-		files2 = os.listdir(newpath)
-		for filename2 in files2:
-			if(filename2==".svn"): continue
-			if(filename2=="@dakota_method"): continue
-			newpath = newclassesdir + filename +'/'+ filename2
-			oldpath = oldclassesdir + filename2
-			shutil.copy(newpath,oldpath)
+    newpath = newclassesdir + filename
+    oldpath = oldclassesdir + filename
+    if(filename == ".svn"):
+        continue
+    if(filename.endswith(".m")):
+        shutil.copy(newpath, oldpath)
+    if(filename.startswith("@")):
+        shutil.copytree(newpath, oldpath)
+    if(filename == "clusters"):
+        files2 = os.listdir(newpath)
+        for filename2 in files2:
+            if(filename2 == ".svn"):
+                continue
+            newpath = newclassesdir + filename + '/' + filename2
+            oldpath = oldclassesdir + filename2
+            shutil.copy(newpath, oldpath)
+    if(filename == "model"):
+        shutil.copy(newpath + '/model.m', oldclassesdir + 'model.m')
+    if(filename == "qmu"):
+        shutil.copytree(newpath + '/@dakota_method', oldclassesdir + '/@dakota_method')
+        files2 = os.listdir(newpath)
+        for filename2 in files2:
+            if(filename2 == ".svn"):
+                continue
+            if(filename2 == "@dakota_method"):
+                continue
+            newpath = newclassesdir + filename + '/' + filename2
+            oldpath = oldclassesdir + filename2
+            shutil.copy(newpath, oldpath)
 
 files = os.listdir(oldclassesdir)
 #prepare properties
 #{{{
-propertiesfile = open(oldclassesdir+'/properties.m','w')
-propertiesfile.write("function out=properties(classname)\n");
+propertiesfile = open(oldclassesdir + '/properties.m', 'w')
+propertiesfile.write("function out = properties(classname)\n")
 #}}}
 for file in files:
-	if(not file.endswith(".m")): continue;
-	print "converting " + file + " from new to old Matlab class definition..."
-	infile     = open(oldclassesdir+file,'r')
-	classname  = (re.compile(r"\.m")).sub("",file)
-	dirname    = oldclassesdir+'/@'+classname
-	step       = 0
-	properties = ""
+    if(not file.endswith(".m")):
+        continue
+    print("converting " + file + " from new to old Matlab class definition...")
+    infile = open(oldclassesdir + file, 'r')
+    classname = (re.compile(r"\.m")).sub("", file)
+    dirname = oldclassesdir + '/@' + classname
+    step = 0
+    properties = ""
 
-	#create directory
-	if(not os.path.exists(dirname)):
-		#print "Directory " + dirname + " does not exist, creating...";
-		os.mkdir(dirname)
+    #create directory
+    if(not os.path.exists(dirname)):
+        #print "Directory " + dirname + " does not exist, creating..."
+        os.mkdir(dirname)
 
-	#Process file
-	file_text  = infile.readlines()
-	for i in range(len(file_text)-2):
-		mystr  = file_text[i];
+    #Process file
+    file_text = infile.readlines()
+    for i in range(len(file_text) - 2):
+        mystr = file_text[i]
 
-		if("properties" in mystr and step==0): step  = 1; continue
-		if("methods"    in mystr and step==1): step  = 2; continue
-		if("function "   in mystr and step==2): step += 1; 
+        if("properties" in mystr and step == 0):
+            step = 1
+            continue
+        if("methods" in mystr and step == 1):
+            step = 2
+            continue
+        if("function " in mystr and step == 2):
+            step += 1
 
-		if(step==1):
-			if("end" in mystr): continue
-			property = mystr.lstrip();
-			property = re.sub(r"%.*$","",property);
-			property = re.sub(r"\n","",property);
-			if(len(property)):
-				properties = properties + 'OBJ' + property + ";\n"
+        if(step == 1):
+            if("end" in mystr):
+                continue
+            property = mystr.lstrip()
+            property = re.sub(r"%. * $", "", property)
+            property = re.sub(r"\n", "", property)
+            if(len(property)):
+                properties = properties + 'OBJ' + property + ";\n"
 
-		if("function " in mystr):
+        if("function " in mystr):
 
-			#close previous file
-			if(step>3): outfile.close()
+            #close previous file
+            if(step > 3):
+                outfile.close()
 
-			#get function name
-			mystr2 = (re.compile("=")).sub(" ",mystr); #replaces equal signs by blank space
-			mystr2 = (re.compile("\(")).sub(" ( ",mystr2); #add blank spaces before and after (
-			list=mystr2.split();
-			for j in range(len(list)):
-				word=list[j];
-				if(word=='('): break
-			objectname   = list[1]
-			functionname = list[j-1]
-			objectname = re.sub("\[","",objectname);
-			objectname = re.sub("\]","",objectname);
-			if(functionname == "disp"): functionname = "display"
-			outfile = open(dirname + '/' + functionname + '.m','w')
+            #get function name
+            mystr2 = (re.compile("=")).sub(" ", mystr)  #replaces equal signs by blank space
+            mystr2 = (re.compile(r"\(")).sub(" (", mystr2)  #add blank spaces before and after (
+            list = mystr2.split()
+            for j in range(len(list)):
+                word = list[j]
+                if(word == '('):
+                    break
+            objectname = list[1]
+            functionname = list[j - 1]
+            objectname = re.sub(r"\[", "", objectname)
+            objectname = re.sub(r"\]", "", objectname)
+            if(functionname == "disp"):
+                functionname = "display"
+            outfile = open(dirname + '/' + functionname + '.m', 'w')
 
-			#deal with constructor
-			if(functionname==classname):
+            #deal with constructor
+            if(functionname == classname):
 
-				properties2 = re.sub("OBJ",objectname + '.',properties);
-				#write function declaration
-				outfile.write(mystr)
-				#write properties
-				outfile.write(properties2)
-				#write set class
-				outfile.write(objectname + "=class(" + objectname + ",'" + classname + "');\n")
+                properties2 = re.sub("OBJ", objectname + '.', properties)
+                #write function declaration
+                outfile.write(mystr)
+                #write properties
+                outfile.write(properties2)
+                #write set class
+                outfile.write(objectname + "=class(" + objectname + ", '" + classname + "');\n")
 
-				#update properties list
-				properties2=properties2.split('\n')
-				propertiesfile2 = open(dirname + '/properties.m','w')
-				propertiesfile2.write("function out=properties(obj),\n")
-				propertiesfile2.write('\tout=cell('+str(len(properties2)-1)+',1);\n')
-				propertiesfile.write("if strcmp(classname,'"+ classname +"'),\n")
-				propertiesfile.write('\tout=cell('+str(len(properties2)-1)+',1);\n')
-				for j in range(len(properties2)-1):
-					property = re.sub(r"=.*$","",properties2[j]);
-					property = property.strip()
-					property = re.sub(objectname+'.',"",property);
-					propertiesfile.write('\tout{' + str(j+1) + "}='" + property + "';\n")
-					propertiesfile2.write('\tout{' + str(j+1) + "}='" + property + "';\n")
-				propertiesfile.write('end\n')
-				continue
+                #update properties list
+                properties2 = properties2.split('\n')
+                propertiesfile2 = open(dirname + '/properties.m', 'w')
+                propertiesfile2.write("function out = properties(obj), \n")
+                propertiesfile2.write('\tout = cell(' + str(len(properties2) - 1) + ', 1);\n')
+                propertiesfile.write("if strcmp(classname, '" + classname + "'), \n")
+                propertiesfile.write('\tout = cell(' + str(len(properties2) - 1) + ', 1);\n')
+                for j in range(len(properties2) - 1):
+                    property = re.sub(r"=. * $", "", properties2[j])
+                    property = property.strip()
+                    property = re.sub(objectname + '.', "", property)
+                    propertiesfile.write('\tout{' + str(j + 1) + "} = '" + property + "';\n")
+                    propertiesfile2.write('\tout{' + str(j + 1) + "} = '" + property + "';\n")
+                propertiesfile.write('end\n')
+                continue
 
-		#write file
-		if(step>2): outfile.write(mystr)
+        #write file
+        if(step > 2):
+            outfile.write(mystr)
 
-	#close all files and delete m file
-	if(step>3):outfile.close()
-	infile.close()
-	os.remove(oldclassesdir+file)
+    #close all files and delete m file
+    if(step > 3):
+        outfile.close()
+    infile.close()
+    os.remove(oldclassesdir + file)
 
-	#Add subsref and subsasgn
-	outfile = open(dirname+'/subsasgn.m','w')
-	outfile.write(subsasgntext)
-	outfile.close()
-	outfile = open(dirname+'/subsref.m','w')
-	outfile.write(subsreftext)
-	outfile.close()
+    #Add subsref and subsasgn
+    outfile = open(dirname + '/subsasgn.m', 'w')
+    outfile.write(subsasgntext)
+    outfile.close()
+    outfile = open(dirname + '/subsref.m', 'w')
+    outfile.write(subsreftext)
+    outfile.close()
 
 
Index: /issm/trunk-jpl/scripts/mToPy.py
===================================================================
--- /issm/trunk-jpl/scripts/mToPy.py	(revision 24211)
+++ /issm/trunk-jpl/scripts/mToPy.py	(revision 24212)
@@ -1,52 +1,56 @@
-#!/usr/bin/env python
+#! / usr / bin / env python
+import sys
+import os
+import shutil
+import translateToPy
+import mToPy  # touch mToPy to assertain location of installation
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 #
-program =               'mToPy.py'
-version =               '1.0'
-versionReleaseDate =    '09/24/12'
-origAuthor =            'Mike Pellegrin'
+program = 'mToPy.py'
+version = '1.0'
+versionReleaseDate = '09/24/12'
+origAuthor = 'Mike Pellegrin'
 desc = '\nMain control unit for converting an matlab script file to python'
 #
 #   Note: Output will be put in the same (absolute) location as the input.
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-#				History
-#	Date		Developer           Modification
+#                History
+#    Date        Developer           Modification
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-#	09/24/12	Michael Pellegrin	Initial Release         V1.0
+#    09 / 24 / 12    Michael Pellegrin    Initial Release         V1.0
 #
 #
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-import sys, os, shutil
-import translateToPy
-import mToPy   # touch mToPy to assertain location of installation
 
-def convert ( inputFile ):
+def convert(inputFile):
     try:
-      if os.path.exists( inputFile + '.m') and os.path.isfile( inputFile + '.m'):
-        checkBackupOutputFile( inputFile )
-        convertMToPy( inputFile )
-      else:
-        print 'Specified input file: ' + inputFile + '.m doesn\'t appear to exist'
+        if os.path.exists(inputFile + '.m') and os.path.isfile(inputFile + '.m'):
+            checkBackupOutputFile(inputFile)
+            convertMToPy(inputFile)
+        else:
+            print('Specified input file: ' + inputFile + '.m doesn\'t appear to exist')
     finally:
-      print ''
+        print('')
 
-def convertMToPy ( inputFileName ):
-    translateToPy.convertToPython ( inputFileName + '.m', inputFileName + '.py' )
 
-def checkBackupOutputFile ( inputFile ):
+def convertMToPy(inputFileName):
+    translateToPy.convertToPython(inputFileName + '.m', inputFileName + '.py')
+
+
+def checkBackupOutputFile(inputFile):
     mFile = inputFile + '.m'
     pyFile = inputFile + '.py'
-    if os.path.exists( pyFile ):
-        i=1
+    if os.path.exists(pyFile):
+        i = 1
         bkupName = pyFile + str(i)
-        while os.path.exists( bkupName ):
-            i+=1
+        while os.path.exists(bkupName):
+            i += 1
             bkupName = pyFile + str(i)
-        os.rename( pyFile, bkupName )
+        os.rename(pyFile, bkupName)
 
     shutil.copyfile(mFile, pyFile)
 
+
 if __name__ == "__main__":
-    convert( sys.argv[1])
-
+    convert(sys.argv[1])
Index: /issm/trunk-jpl/scripts/translateToPy.py
===================================================================
--- /issm/trunk-jpl/scripts/translateToPy.py	(revision 24211)
+++ /issm/trunk-jpl/scripts/translateToPy.py	(revision 24212)
@@ -1,22 +1,24 @@
+
+import codecs
+import unicodedata
+import sys
+import datetime
+import os
 
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 #
-program =               'translateToPy.py'
-version =               '1.0'
-versionReleaseDate =    '09/24/12'
-origAuthor =            'Mike Pellegrin'
+program = 'translateToPy.py'
+version = '1.0'
+versionReleaseDate = '09/24/12'
+origAuthor = 'Mike Pellegrin'
 desc = '\nMatlab script conversion into python'
 #
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-#				History
-#	Date		Developer           Modification
-#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-#	09/24/12 Michael Pellegrin	Initial Release     V1.0
+#                History
+#    Date        Developer           Modification
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#    09 / 24 / 12 Michael Pellegrin    Initial Release     V1.0
 #
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-import codecs, unicodedata
-import sys, re, datetime, os
-import decimal, operator
 
 
@@ -28,229 +30,228 @@
 
 
-def setupOutputLocation ( outFile ):
+def setupOutputLocation(outFile):
     if outFile != sys.stdout:
-		globals()['outputLocation'] = open( outFile, 'w' ) # clobber
-
-def translateFile ( inputFile ):
-	f = codecs.open( inputFile, encoding='utf-8' )
-	try:
-		for line in f:
-			# print "in: " +line
-
-			asciiLine = unicodedata.normalize('NFKD', line).encode('ascii','ignore')
-			line = asciiLine
-
-			translateLine( line )
-
-	finally:
-		f.close()
-
-def translateLine ( line ):
-
-	if len(line) == 1:	# blank line
-		output( line )
-
-	elif line.split()[0][0] == '%':		# comment line
-		output("# " + line.replace('%','') )
-
-	else:		# needs cleanup.  this is a real-quick-n-dirty implimentation
-		#print line
-		res = line.replace('{','[')
-		res = res.replace('}',']')
-		res = res.replace('model','model()')
-		res = res.replace('SolutionEnum','SolutionEnum()')
-		res = res.replace('StressTensorEnum','StressTensorEnum()')
-		res = res.replace('.par','.py')
-		res = res.replace('=extrude(md,','.extrude(')
-
-		res = res.replace('thickness(pos)','thickness[pos]')
-		res = res.replace('find(md.','numpy.nonzero(md.')
-
-		res = res.replace('\n','')
-
-		# handle inline comments
-		res = res.replace('%','#')
-
-		res = res.replace('...','\\')
-
-		# determine if the m file has mult. line cmd (real quick solution)
-		multCmds = res.split(';')
-		numLines = len( multCmds ) - 2
-		allParts = ''
-		for part in multCmds:
-			allParts += part
-			#allParts += re.sub('^\s+','',part)
-			#allParts += part.strip()
-			if numLines > 0:
-				allParts += '\n'
-				numLines -= 1
-		res = allParts	
-
-		res = res.replace(';','')
-
-
-		res = convertFieldValues( res )
-		#print 'resulting line:' + str(res) + '\n'
-		output(res)
-
-def convertFieldValues ( currentLine ):
-	# before utilizing regex's {starting w/ eg. \([0-9]\) } for special case: ...(#)...
-	# i noticed what i'm looking for is only TransientSolution(*). So, ...
-
-	res = currentLine
-	if 'md.results' in currentLine:
-		res = res.replace('(md.results.','md.results[\'')
-
-		if 'TransientSolution(' in currentLine:		# got a TransientSolution([0-9..]) case
-			res = res.replace('TransientSolution(','TransientSolution\'][')
-			parts = res.split(')')
-			res = parts[0] + '][\'' + parts[1].replace('.','') + '\']' + parts[2]
-
-		else:				# handle the other cases for md.results
-			
-			res = res.replace('Solution.Vx)','Solution\'][1][\'Vx\']')
-			res = res.replace('Solution.Vy)','Solution\'][1][\'Vy\']')
-			res = res.replace('Solution.Vz)','Solution\'][1][\'Vz\']')
-			res = res.replace('Solution.Vel)','Solution\'][1][\'Vel\']')
-
-			res = res.replace('Solution.Pressure)','Solution\'][1][\'Pressure\']')
-
-			res = res.replace('Solution.StressTensorxx)','Solution\'][1][\'StressTensorxx\']')
-			res = res.replace('Solution.StressTensorxy)','Solution\'][1][\'StressTensorxy\']')
-			res = res.replace('Solution.StressTensoryy)','Solution\'][1][\'StressTensoryy\']')
-			res = res.replace('Solution.StressTensorzz)','Solution\'][1][\'StressTensorzz\']')
-			res = res.replace('Solution.StressTensorxz)','Solution\'][1][\'StressTensorxz\']')
-			res = res.replace('Solution.StressTensoryz)','Solution\'][1][\'StressTensoryz\']')
-
-			res = res.replace('Solution.FrictionCoefficient)','Solution\'][1][\'FrictionCoefficient\']')
-			res = res.replace('Solution.SurfaceforcingsMasBalance)','Solution\'][1][\'SurfaceforcingsMasBalance\']')
-			res = res.replace('Solution.MaskElementonfloatingice)','Solution\'][1][\'MaskElementonfloatingice\']')
-			res = res.replace('Solution.J)','Solution\'][1][\'J\']')
-			res = res.replace('Solution.BalancethicknessThickeningRate)','Solution\'][1][\'BalancethicknessThickeningRate\']')
-
-			res = res.replace('Solution.Gradient1)','Solution\'][1][\'Gradient1\']')
-			res = res.replace('Solution.Gradient2)','Solution\'][1][\'Gradient2\']')
-
-			res = res.replace('Solution.MaterialsRheologyZbar)','Solution\'][1][\'MaterialsRheologyZbar\']')
-			res = res.replace('Solution.MaterialsRheologyBbar)','Solution\'][1][\'MaterialsRheologyBbar\']')
-			res = res.replace('Solution.MaterialsRheologyB)','Solution\'][1][\'MaterialsRheologyB\']')
-
-			res = res.replace('Solution.Thickness)','Solution\'][1][\'Thickness\']')
-
-			res = res.replace('Solution.Temperature)','Solution\'][1][\'Temperature\']')
-
-			res = res.replace('Solution.BasalforcingsMeltingRate)','Solution\'][1][\'BasalforcingsMeltingRate\']')
-
-			res = res.replace('Solution.SurfaceSlopeX)','Solution\'][1][\'SurfaceSlopeX\']')
-			res = res.replace('Solution.SurfaceSlopeY)','Solution\'][1][\'SurfaceSlopeY\']')
-			res = res.replace('Solution.SurfaceSlopeZ)','Solution\'][1][\'SurfaceSlopeZ\']')
-
-			res = res.replace('Solution.BedSlopeX)','Solution\'][1][\'BedSlopeX\']')
-			res = res.replace('Solution.BedSlopeY)','Solution\'][1][\'BedSlopeY\']')
-			res = res.replace('Solution.BedSlopeZ)','Solution\'][1][\'BedSlopeZ\']')
-
-			res = res.replace('Solution.Enthalpy)','Solution\'][1][\'Enthalpy\']')
-			res = res.replace('Solution.Waterfraction)','Solution\'][1][\'Waterfraction\']')
-			res = res.replace('Solution.Temperature)','Solution\'][1][\'Temperature\']')
-
-			# special case
-			res = res.replace('.DiagnosticSolution.J','[\'DiagnosticSolution\'][1][\'J\']')
-
-	return res
-
-def output ( line ):
-	numTabs = indentLevel
-	while numTabs:
-		numTabs -= 1
-		print >> outputLocation, '\t',
-	print >> outputLocation, line
-
-def outputTopOfSript( inputFile ):
-
-	global indentLevel
-
-	output("\"\"\"")
-	output("== == == == == == == == == == == == == == == == == == ==")
-	output("Auto generated python script for ISSM:   %s" % (inputFile) )
-	output("Created on %s via %s Ver %s by %s" % ( datetime.date.today(), program, version, os.getlogin()))
-	output("== == == == == == == == == == == == == == == == == == ==")
-	#output("")
-	output(desc)
-	output("%s Author: Michael Pellegrin" % (program))
-	output("%s Date: %s" % (program, versionReleaseDate))
-	output("== == == == == == == == == == == == == == == == == == ==")
-	output("\"\"\"")
-	output("")
+        globals()['outputLocation'] = open(outFile, 'w')  # clobber
+
+
+def translateFile(inputFile):
+    f = codecs.open(inputFile, encoding='utf-8')
+    try:
+        for line in f:
+            # print "in: " + line
+
+            asciiLine = unicodedata.normalize('NFKD', line).encode('ascii', 'ignore')
+            line = asciiLine
+            translateLine(line)
+
+    finally:
+        f.close()
+
+
+def translateLine(line):
+
+    if len(line) == 1:    # blank line
+        output(line)
+
+    elif line.split()[0][0] == '%':        # comment line
+        output("# " + line.replace('%', ''))
+
+    else:        # needs cleanup.  this is a real - quick - n - dirty implimentation
+        #print line
+        res = line.replace('{', '[')
+        res = res.replace('}', ']')
+        res = res.replace('model', 'model()')
+        res = res.replace('SolutionEnum', 'SolutionEnum()')
+        res = res.replace('StressTensorEnum', 'StressTensorEnum()')
+        res = res.replace('.par', '.py')
+        res = res.replace('=extrude(md, ', '.extrude(')
+
+        res = res.replace('thickness(pos)', 'thickness[pos]')
+        res = res.replace('find(md.', 'numpy.nonzero(md.')
+
+        res = res.replace('\n', '')
+
+        # handle inline comments
+        res = res.replace('%', '#')
+
+        res = res.replace('...', '\\')
+
+        # determine if the m file has mult. line cmd (real quick solution)
+        multCmds = res.split(';')
+        numLines = len(multCmds) - 2
+        allParts = ''
+        for part in multCmds:
+            allParts += part
+            #allParts += re.sub('^\s + ', '', part)
+            #allParts += part.strip()
+            if numLines > 0:
+                allParts += '\n'
+                numLines -= 1
+
+        res = allParts
+        res = res.replace(';', '')
+        res = convertFieldValues(res)
+        #print 'resulting line:' + str(res) + '\n'
+        output(res)
+
+
+def convertFieldValues(currentLine):
+    # before utilizing regex's {starting w / eg. \([0 - 9]\) } for special case: ...(#)...
+    # i noticed what i'm looking for is only TransientSolution(* ). So, ...
+
+    res = currentLine
+    if 'md.results' in currentLine:
+        res = res.replace('(md.results.', 'md.results[\'')
+
+        if 'TransientSolution(' in currentLine:        # got a TransientSolution([0 - 9..]) case
+            res = res.replace('TransientSolution(', 'TransientSolution\'][')
+            parts = res.split(')')
+            res = parts[0] + '][\'' + parts[1].replace('.', '') + '\']' + parts[2]
+
+        else:                # handle the other cases for md.results
+
+            res = res.replace('Solution.Vx)', 'Solution\'][1][\'Vx\']')
+            res = res.replace('Solution.Vy)', 'Solution\'][1][\'Vy\']')
+            res = res.replace('Solution.Vz)', 'Solution\'][1][\'Vz\']')
+            res = res.replace('Solution.Vel)', 'Solution\'][1][\'Vel\']')
+
+            res = res.replace('Solution.Pressure)', 'Solution\'][1][\'Pressure\']')
+
+            res = res.replace('Solution.StressTensorxx)', 'Solution\'][1][\'StressTensorxx\']')
+            res = res.replace('Solution.StressTensorxy)', 'Solution\'][1][\'StressTensorxy\']')
+            res = res.replace('Solution.StressTensoryy)', 'Solution\'][1][\'StressTensoryy\']')
+            res = res.replace('Solution.StressTensorzz)', 'Solution\'][1][\'StressTensorzz\']')
+            res = res.replace('Solution.StressTensorxz)', 'Solution\'][1][\'StressTensorxz\']')
+            res = res.replace('Solution.StressTensoryz)', 'Solution\'][1][\'StressTensoryz\']')
+
+            res = res.replace('Solution.FrictionCoefficient)', 'Solution\'][1][\'FrictionCoefficient\']')
+            res = res.replace('Solution.SurfaceforcingsMasBalance)', 'Solution\'][1][\'SurfaceforcingsMasBalance\']')
+            res = res.replace('Solution.MaskElementonfloatingice)', 'Solution\'][1][\'MaskElementonfloatingice\']')
+            res = res.replace('Solution.J)', 'Solution\'][1][\'J\']')
+            res = res.replace('Solution.BalancethicknessThickeningRate)', 'Solution\'][1][\'BalancethicknessThickeningRate\']')
+
+            res = res.replace('Solution.Gradient1)', 'Solution\'][1][\'Gradient1\']')
+            res = res.replace('Solution.Gradient2)', 'Solution\'][1][\'Gradient2\']')
+
+            res = res.replace('Solution.MaterialsRheologyZbar)', 'Solution\'][1][\'MaterialsRheologyZbar\']')
+            res = res.replace('Solution.MaterialsRheologyBbar)', 'Solution\'][1][\'MaterialsRheologyBbar\']')
+            res = res.replace('Solution.MaterialsRheologyB)', 'Solution\'][1][\'MaterialsRheologyB\']')
+
+            res = res.replace('Solution.Thickness)', 'Solution\'][1][\'Thickness\']')
+
+            res = res.replace('Solution.Temperature)', 'Solution\'][1][\'Temperature\']')
+
+            res = res.replace('Solution.BasalforcingsMeltingRate)', 'Solution\'][1][\'BasalforcingsMeltingRate\']')
+
+            res = res.replace('Solution.SurfaceSlopeX)', 'Solution\'][1][\'SurfaceSlopeX\']')
+            res = res.replace('Solution.SurfaceSlopeY)', 'Solution\'][1][\'SurfaceSlopeY\']')
+            res = res.replace('Solution.SurfaceSlopeZ)', 'Solution\'][1][\'SurfaceSlopeZ\']')
+
+            res = res.replace('Solution.BedSlopeX)', 'Solution\'][1][\'BedSlopeX\']')
+            res = res.replace('Solution.BedSlopeY)', 'Solution\'][1][\'BedSlopeY\']')
+            res = res.replace('Solution.BedSlopeZ)', 'Solution\'][1][\'BedSlopeZ\']')
+
+            res = res.replace('Solution.Enthalpy)', 'Solution\'][1][\'Enthalpy\']')
+            res = res.replace('Solution.Waterfraction)', 'Solution\'][1][\'Waterfraction\']')
+            res = res.replace('Solution.Temperature)', 'Solution\'][1][\'Temperature\']')
+
+            # special case
+            res = res.replace('.DiagnosticSolution.J', '[\'DiagnosticSolution\'][1][\'J\']')
+
+    return res
+
+
+def output(line):
+    numTabs = indentLevel
+    while numTabs:
+        numTabs -= 1
+        print('\t', end="", file=outputLocation)
+
+    print(line, end="", file=outputLocation)
+
+
+def outputTopOfSript(inputFile):
+
+    global indentLevel
+
+    output("\"\"\"")
+    output("====================================== ")
+    output("Auto generated python script for ISSM: {}".format(inputFile))
+    output("Created on {} via {} Ver {} by {}".format(datetime.date.today(), program, version, os.getlogin()))
+    output("====================================== ")
+    #output("")
+    output(desc)
+    output("%s Author: Michael Pellegrin" % (program))
+    output("%s Date: %s" % (program, versionReleaseDate))
+    output("====================================== ")
+    output("\"\"\"")
+    output("")
+
 
 def outputBottomOfScript():
 
-	global indentLevel
-
-	output("")
-	
-def genericImports ():
-	output("from MatlabFuncs import *")
-	output("from model import *")
-	output("from EnumDefinitions import *")
-	output("from numpy import *")
-
-def createImports ( inputFile ):
-	genericImports()
-
-	# cycle through eachline to assertain import needs
-	f = codecs.open( inputFile, encoding='utf-8' )
-	try:
-		for line in f:
-			# print "in: " +line
-
-			# toss blank lines
-			if len(line) == 1:
-				continue
-
-			asciiLine = unicodedata.normalize('NFKD', line).encode('ascii','ignore')
-			line = asciiLine
-
-			for il in importList:
-				if line.find(il) != -1:
-					output( "from %s import *" % (il) )
-					importList.remove(il)	# already got it
-
-	finally:
-		output("")
-		f.close()
-
-
-def initImportList ():
-	global importList
-	
-	importList = [ \
-		'triangle'	,\
-		'setmask'	,\
-		'parameterize'	,\
-		'setflowequation'	,\
-		'meshconvert'	,\
-		'solve'	,\
-		#'zeros'					# -> numpy
-		]
-	
-
-
-def convertToPython ( inFile, outFile = sys.stdout ):
-    #print ' in cnvrt to python w/ file:' + inFile
+    global indentLevel
+
+    output("")
+
+
+def genericImports():
+    output("from MatlabFuncs import * ")
+    output("from model import * ")
+    output("from EnumDefinitions import * ")
+    output("from numpy import * ")
+
+
+def createImports(inputFile):
+    genericImports()
+
+    # cycle through eachline to assertain import needs
+    f = codecs.open(inputFile, encoding='utf-8')
+    try:
+        for line in f:
+            # print "in: " + line
+
+            # toss blank lines
+            if len(line) == 1:
+                continue
+
+            asciiLine = unicodedata.normalize('NFKD', line).encode('ascii', 'ignore')
+            line = asciiLine
+
+            for il in importList:
+                if line.find(il) != - 1:
+                    output("from %s import * " % (il))
+                    importList.remove(il)    # already got it
+
+    finally:
+        output("")
+        f.close()
+
+
+def initImportList():
+    global importList
+
+    importList = ['triangle',
+                  'setmask',
+                  'parameterize',
+                  'setflowequation',
+                  'meshconvert',
+                  'solve']
+
+
+def convertToPython(inFile, outFile=sys.stdout):
+    #print ' in cnvrt to python w / file:' + inFile
     initImportList()
-    setupOutputLocation( outFile )
-    outputTopOfSript( inFile )
-    createImports( inFile )
-    translateFile( inFile )
+    setupOutputLocation(outFile)
+    outputTopOfSript(inFile)
+    createImports(inFile)
+    translateFile(inFile)
     #    outputBottomOfScript()
 
-	
+
 if __name__ == "__main__":
-    #print ' in main w/ arg:' + sys.argv[1]+' '+sys.argv[2]
-    if len(sys.argv)==2:
-        convertToPython( sys.argv[1], sys.argv[2] )
+    #print ' in main w / arg:' + sys.argv[1] + ' ' + sys.argv[2]
+    if len(sys.argv) == 2:
+        convertToPython(sys.argv[1], sys.argv[2])
     else:
-        convertToPython( sys.argv[1] )
-
-
-
+        convertToPython(sys.argv[1])
