old_contents: import fast_io
  import numpy as np
  import sys, os
  
  if __name__=="__main__":
      fin1 = sys.argv[1]
      fin2 = sys.argv[2]
      maxTol = sys.argv[3]
  
      try:
          d1, i1 = fast_io.load_binary_output(fin1)
      except:
          print "Problem reading file ", fin1
  
      try:
          d2, i2 = fast_io.load_binary_output(fin2)
      except:
          print "Problem reading file ", fin2
  
      nCols = np.size(d1,1)
      var = np.ones(nCols)
      for j in range(nCols):
          var[j] = (d1[:,j]-d2[:,j]).var()
  
      if (max(var) < maxTol):
          sys.exit(0)
      else:
          print "var = ", var
          print i1['attribute_names']
          sys.exit(1)
  
new_contents: import sys, os
  import numpy as np
  from fast_io import load_binary_output
  
  def exitWithError(error):
      print error
      sys.exit(-1)
  
  # validate input arguments
  nArgsExpected = 4
  if len(sys.argv) < nArgsExpected:
      exitWithError("Error: {} arguments given, expected {}\n".format(len(sys.argv), nArgsExpected) +
          "Usage: {} solution1 solution2 tolerance".format(sys.argv[0]))
  
  solutionFile1 = sys.argv[1]
  solutionFile2 = sys.argv[2]
  solutionTolerance = sys.argv[3]
  
  if not os.path.isfile(solutionFile1):
      exitWithError("Error: solution file does not exist at {}".format(solutionFile1))
  
  if not os.path.isfile(solutionFile2):
      exitWithError("Error: solution file does not exist at {}".format(solutionFile2))
  
  try:
      solutionTolerance = float(solutionTolerance)
  except ValueError:
      exitWithError("Error: invalid tolerance given, {}".format(solutionTolerance))
  
  # parse the FAST solution files
  try:
      dict1, info1 = load_binary_output(solutionFile1)
      dict2, info2 = load_binary_output(solutionFile2)
  except Exception as e:
      exitWithError("Error: {}".format(e))
  
  # calculate the difference in solutions
  nColumns = np.size(dict1,1)
  variance = np.ones(nColumns)
  for j in range(nColumns):
      variance[j] = (dict1[:,j]-dict2[:,j]).var()
  
  if max(variance) < solutionTolerance:
      print "ok"
      sys.exit(0)
  else:
      print info1['attribute_names']
      print "var = ", variance
      sys.exit(1)
  
subject: improve argument validation and error handling