Index: /issm/trunk-jpl/test/NightlyRun/runme.py
===================================================================
--- /issm/trunk-jpl/test/NightlyRun/runme.py	(revision 27609)
+++ /issm/trunk-jpl/test/NightlyRun/runme.py	(revision 27610)
@@ -1,10 +1,5 @@
-#!/usr/bin/env python
-#
-# NOTE: Switch to,
-#
-#   #!/usr/bin/python3
-#
-# when making Python 3 default
-#
+#!/usr/bin/env python3
+
+
 import argparse
 import os
@@ -31,5 +26,5 @@
 
 def runme(id=None, exclude=None, benchmark='nightly', procedure='check', output='none', rank=1, numprocs=1):
-    """RUNME - test deck for ISSM nightly runs
+    """runme - test deck for ISSM nightly runs
 
     In a test deck directory (for example, test/NightlyRun) the following
@@ -91,59 +86,59 @@
     """
 
-    #Get ISSM_DIR variable
+    # Get ISSM_DIR variable
     ISSM_DIR = os.environ['ISSM_DIR']
 
-    #Process options
-    #GET benchmark {{{
+    # Process options
+    # Get benchmark {{{
     if benchmark not in ['all', 'nightly', 'validation', 'adolc', 'eismint', 'ismip', 'mesh', 'slc', 'thermal', 'tranforcing', 'qmu']:
         print(("runme warning: benchmark '{}' not supported, defaulting to test 'nightly'.".format(benchmark)))
         benchmark = 'nightly'
     # }}}
-    #GET procedure {{{
+    # Get procedure {{{
     if procedure not in ['check', 'update', 'runFromNC']:
         print(("runme warning: procedure '{}' not supported, defaulting to test 'check'.".format(procedure)))
         procedure = 'check'
     # }}}
-    #GET output {{{
+    # Get output {{{
     if output not in ['nightly', 'none']:
         print(("runme warning: output '{}' not supported, defaulting to test 'none'.".format(output)))
         output = 'none'
     # }}}
-    #GET RANK and NUMPROCS for multithreaded runs {{{
+    # Get rank and numprocs for multi-threaded runs {{{
     if (numprocs < rank):
         numprocs = 1
     # }}}
-    #GET ids  {{{
+    # Get ids  {{{
     flist = [f for f in os.listdir('.') if re.match('test[0-9]+.py', f)] # File name must follow the format "test<integer>.py"
     list_ids = [int(re.search(r'\d+',f.split('.')[0]).group()) for f in flist] # Retrieve test IDs
     i1, i2 = parallelrange(rank, numprocs, len(list_ids))  # Get tests for this CPU only
     list_ids = list_ids[i1:i2 + 1]
-    if np.size(id) > 0 and id is not None:
+    if len(id) > 0 and id is not None:
         test_ids = set(GetIds(id)).intersection(set(list_ids))
         benchmark = None
     else:
-        # if no tests are specifically provided, do them all
+        # If no tests are specifically provided, do them all
         test_ids = set(list_ids)
 
     # }}}
-    #GET exclude {{{
+    # Get excluded tests {{{
     exclude_ids = GetIds(exclude)
     test_ids = test_ids.difference(exclude_ids)
     # }}}
     if procedure == 'runFromNC':
-        #That is a bamg test
+        # bamg test
         test_ids = test_ids.difference([119, 514])
-        # that is smbGEMB format is weird for the test
+        # smbGEMB format is weird for the test
         test_ids = test_ids.difference([243, 244, 252, 253])
-        #those are amr runs where the index is missing from fieldnames
+        # AMR runs where the index is missing from fieldnames
         test_ids = test_ids.difference([462, 463, 464, 465])
-        #test247 solves for thermal and transient which makes it complex to check
+        # test247 solves for thermal and transient which makes it complex to check
         test_ids = test_ids.difference([247])
-        #test 902 is running two models with different stepping
+        # test 902 is running two models with different stepping
         test_ids = test_ids.difference([902])
-        #I have a size issue in 517 needs investigation
+        # size issue in 517 needs investigation
         test_ids = test_ids.difference([517])
 
-    #Process Ids according to benchmarks {{{
+    # Process IDs according to benchmarks {{{
     if benchmark == 'nightly':
         test_ids = test_ids.intersection(set(range(1, 1000)))
@@ -172,5 +167,5 @@
     # }}}
 
-    #Loop over tests and launch sequence
+    # Loop over tests and launch sequence
     root = os.getcwd()
     errorcount = 0
@@ -179,5 +174,5 @@
         print(("----------------starting:{}-----------------------".format(id)))
         try:
-            #Execute test
+            # Execute test
             os.chdir(root)
             id_string = IdToName(id)
@@ -188,5 +183,5 @@
                 exec(compile(open('test{}.py'.format(id)).read(), 'test{}.py'.format(id), 'exec'), globals())
 
-            #UPDATE ARCHIVE?
+            # Update archive?
             archive_name = 'Archive' + str(id)
             if procedure == 'update':
@@ -213,13 +208,13 @@
                         solvetype = re.split('Solution', key)[0]
 
-                #we save the results, scrap them and solve.
+                # Save the results, scrap them and solve
                 loaded_res = mdl.results
                 mdl.results = []
                 mdl = solve(mdl, solvetype)
 
-                #we loop on the field_names from the nghtly test
+                # Loop on the field_names from the nightly test
                 for k, fieldname in enumerate(Tmod.field_names):
                     try:
-                        #first look for indexing
+                        # First, look for indexing
                         if re.search(r'\d+$', fieldname):
                             index = int(re.search(r'\d+$', fieldname).group()) - 1
@@ -237,9 +232,9 @@
                             index = 0
 
-                        #Then check if the key exists in the loaded results
+                        # Then, check if the key exists in the loaded results
                         try:
                             reskeys = mdl.results.__dict__[solvetype + 'Solution'][index].__dict__.keys()
                         except TypeError:
-                            # most probably a steady state so no subscripting
+                            # Most likely a steady state so no subscripting
                             reskeys = mdl.results.__dict__[solvetype + 'Solution'].__dict__.keys()
                         if fieldname not in reskeys:
@@ -259,19 +254,19 @@
 
                             if fieldname in namedifs.keys():
-                                #Some fields are not consistent
+                                # Some fields are not consistent
                                 fieldname = namedifs[fieldname]
                             elif any([suf in fieldname for suf in sufixes]):
-                                #some test have loops that mess up with naming
+                                # Some tests have loops that mess up naming
                                 try:
                                     sufix = sufixes[np.squeeze(np.where([suf in fieldname for suf in sufixes]))]
                                 except TypeError:
-                                    #probably severalmatches, we take the last one which should be the good one (Needs to be controled in the list above)
+                                    # Probably several matches; we take the last one which should be the one we're want to run (needs to be controlled in the list above)
                                     sufix = sufixes[np.squeeze(np.where([suf in fieldname for suf in sufixes]))[-1]]
                                 fieldname = fieldname[:re.search(sufix, fieldname).start()]
                             elif fieldname.endswith("P") and index == 1:
-                                #we are looking for P2 but 2 as been considered as an index and so shifted by -1
+                                # Looking for P2 but 2 refers to an index, so shift by -1
                                 fieldname = fieldname[:-1]
                             else:
-                                # could be that the index selected above is part of the name
+                                # Handle case where index selected above is part of the name
                                 fieldname = fieldname + str(index + 1)
                         try:
@@ -279,5 +274,5 @@
                             loaded_field = loaded_res.__dict__[solvetype + 'Solution'][index].__dict__[fieldname]
                         except TypeError:
-                            # most probably a steady state so no subscripting
+                            # Most likely a steady state so no subscripting
                             try:
                                 field = mdl.results.__dict__[solvetype + 'Solution'].__dict__[fieldname]
@@ -291,17 +286,17 @@
 
                         ref = Tmod.field_values[k]
-                        #Get tolerance
+                        # Get tolerance
                         tolerance = Tmod.field_tolerances[k]
-                        #compute differences for the results computed from the nc file
+                        # Compute differences for the results computed from the nc file
                         error_diff = np.amax(np.abs(ref - field), axis=0) / (np.amax(np.abs(ref), axis=0) + float_info.epsilon)
                         if not np.isscalar(error_diff):
                             error_diff = error_diff[0]
 
-                        #compute the differences for the results of the nc file
+                        # Compute the differences for the results of the nc file
                         load_diff = np.amax(np.abs(np.squeeze(ref) - loaded_field), axis=0) / (np.amax(np.abs(np.squeeze(ref)), axis=0) + float_info.epsilon)
                         if not np.isscalar(load_diff):
                             load_diff = load_diff[0]
 
-                        #disp test result
+                        # Display test result
                         if (np.any(error_diff > tolerance) or np.isnan(error_diff)) and (np.any(load_diff > tolerance) or np.isnan(load_diff)):
                             if abs(error_diff - load_diff) < tolerance:
@@ -321,8 +316,8 @@
                         else:
                             print(('SUCCESS difference: {:7.2g} < {:7.2g} test id: {} test name: {} field: {}{}'.format(error_diff, tolerance, id, id_string, fieldname, index + 1)))
-                        #disp only if errors for the results
+                        # Display only if there are errors in the results
 
                     except Exception as message:
-                        #something went wrong, print failure message:
+                        # Something went wrong; print failure message
                         print((format_exc()))
                         if output == 'nightly':
@@ -335,7 +330,7 @@
                             print(('FAILURE difference: N/A test id: {} test name: {} field: {}'.format(id, id_string, fieldname)))
                             raise RuntimeError(message)
-            #ELSE: CHECK TEST
+            # Check test
             else:
-                #load archive
+                # Load archive
                 if os.path.exists(os.path.join('..', 'Archives', archive_name + '.arch')):
                     archive_file = os.path.join('..', 'Archives', archive_name + '.arch')
@@ -345,5 +340,5 @@
                 for k, fieldname in enumerate(field_names):
                     try:
-                        #Get field and tolerance
+                        # Get field and tolerance
                         field = np.array(field_values[k])
                         if len(field.shape) == 1:
@@ -354,5 +349,5 @@
                         tolerance = field_tolerances[k]
 
-                        #compare to archive
+                        # Compare to archive
                         # Matlab uses base 1, so use base 1 in labels
                         archive = np.array(archread(archive_file, archive_name + '_field' + str(k + 1)))
@@ -369,5 +364,5 @@
                             error_diff = error_diff[0]
 
-                        #disp test result
+                        # Display test result
                         if (np.any(error_diff > tolerance) or np.isnan(error_diff)):
                             print(('ERROR   difference: {:7.2g} > {:7.2g} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname)))
@@ -378,5 +373,5 @@
 
                     except Exception as message:
-                        #something went wrong, print failure message:
+                        # Something went wrong; print failure message
                         print((format_exc()))
                         if output == 'nightly':
@@ -391,5 +386,5 @@
 
         except Exception as message:
-            #something went wrong, print failure message:
+            # Something went wrong; print failure message
             print((format_exc()))
             if output == 'nightly':
@@ -420,5 +415,5 @@
             print(("PYTHONSTARTUP file '{}' does not exist.".format(PYTHONSTARTUP)))
 
-        parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs')
+        parser = argparse.ArgumentParser(description='runme - test deck for ISSM nightly runs')
         parser.add_argument('-i', '--id', nargs='*', type=str, help='followed by the list of ids requested', default=[])
         parser.add_argument('-in', '--include_name', nargs='*', type=str, help='followed by the list of test names requested', default=[])
