diff --git a/exodus/CMakeLists.txt b/exodus/CMakeLists.txt index a1d8317..47eb531 100644 --- a/exodus/CMakeLists.txt +++ b/exodus/CMakeLists.txt @@ -69,7 +69,7 @@ IF(CURL_FOUND) ENDIF() -find_program(PYTHON "python2") +find_program(PYTHON "python3") if (PYTHON) set(EXODUS_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/exodus.py.in") diff --git a/exodus/exodus.py.in b/exodus/exodus.py.in index 38c77d0..84059a3 100644 --- a/exodus/exodus.py.in +++ b/exodus/exodus.py.in @@ -75,16 +75,16 @@ def getAccessPath(): if not isinstance(accessPth,str) or not os.path.isdir(accessPth): system = os.environ.get('SIERRA_SYSTEM') if not isinstance(system,str): - raise Exception, "Both the $ACCESS path and $SIERRA_SYSTEM are undefined" + raise Exception("Both the $ACCESS path and $SIERRA_SYSTEM are undefined") if system == 'desktop_rh6': accessPth = '/projects/seacas/linux_rhel6/current' elif system == 'desktop' : accessPth = '/projects/seacas/linux_rhel5/current' elif system == 'redsky' : accessPth = '/projects/seacas/redsky/current' elif system == 'tlcc' : accessPth = '/projects/seacas/tlcc/current' elif system == 'tlcc2' : accessPth = '/projects/seacas/tlcc2/current' elif system == 'amech' : accessPth = '/projects/seacas/linux_rhel5/current' - else: raise Exception, "Unrecognized $SIERRA_SYSTEM: %s" % system + else: raise Exception("Unrecognized $SIERRA_SYSTEM: %s" % system) if not os.path.isdir(accessPth): - raise Exception, "Invalid $ACCESS path: %s" % accessPth + raise Exception("Invalid $ACCESS path: %s" % accessPth) return accessPth @@ -97,7 +97,7 @@ def findLibExoPath(): for shLibDir in trialShLibDirs: libExoPth = accessPth + shLibDir if os.path.isdir(libExoPth): return libExoPth - raise Exception, "Shared library sub-directory not found in $ACCESS path: %s" % accessPth + raise Exception("Shared library sub-directory not found in $ACCESS path: %s" % accessPth) EXODUS_PATH = findLibExoPath() if os.uname()[0] == 'Darwin': @@ -237,7 +237,7 @@ class exodus: def __init__(self,file,mode=None,array_type='ctype',title=None,numDims=None, numNodes=None,numElems=None,numBlocks=None, numNodeSets=None,numSideSets=None,io_size=0): - print EXODUS_PY_COPYRIGHT + print(EXODUS_PY_COPYRIGHT) if mode == None: mode = 'r' if array_type == 'numpy': @@ -375,8 +375,8 @@ class exodus: """ for rec in info: if len(str(rec)) > MAX_LINE_LENGTH: - print "WARNING: max line length reached for one or more info records;" - print " info stored to exodus file is incomplete for these records" + print("WARNING: max line length reached for one or more info records;") + print(" info stored to exodus file is incomplete for these records") break if self.__ex_put_info_recs(info): return True @@ -403,15 +403,15 @@ class exodus: if begin: # inside Sierra block sierra_inp.append(rec) if len(rec) > MAX_LINE_LENGTH: - print "WARNING: max line length reached for one or more input lines;" - print " input data might be incomplete for these lines" + print("WARNING: max line length reached for one or more input lines;") + print(" input data might be incomplete for these lines") break if len(vals) >= 2 and vals[0].lower() == "end" and vals[1].lower() == "sierra": break # end of Sierra block if inpFileName: fd = open(inpFileName,"w") for fileLine in sierra_inp: - print >> fd, fileLine + print(fileLine, file=fd) fd.close() return "" else: @@ -599,9 +599,9 @@ class exodus: ndType = ex_entity_type("EX_NODAL") NDvarNames = self.get_node_variable_names() if name in NDvarNames: - print "WARNING:node variable \"", name, "\" already exists." + print("WARNING:node variable \"", name, "\" already exists.") if index > len(NDvarNames): - raise Exception, ("ERROR: variable index out of range.") + raise Exception(("ERROR: variable index out of range.")) self.__ex_put_variable_name(ndType,index,name) return True @@ -979,10 +979,10 @@ class exodus: ebType = ex_entity_type("EX_ELEM_BLOCK") EBvarNames = self.get_element_variable_names() if name in EBvarNames: - print "WARNING:element variable \"", name, "\" already exists." + print("WARNING:element variable \"", name, "\" already exists.") if index > len(EBvarNames): - print "index", index, "len", len(EBvarNames) - raise Exception, ("ERROR: variable index out of range.") + print("index", index, "len", len(EBvarNames)) + raise Exception(("ERROR: variable index out of range.")) self.__ex_put_variable_name(ebType,index,name) return True @@ -1236,9 +1236,9 @@ class exodus: nsType = ex_entity_type("EX_NODE_SET") NSvarNames = self.get_node_set_variable_names() if name in NSvarNames: - print "WARNING: Node set variable \"", name, "\" already exists." + print("WARNING: Node set variable \"", name, "\" already exists.") if index > len(NSvarNames): - raise Exception, ("ERROR: variable index out of range.") + raise Exception(("ERROR: variable index out of range.")) self.__ex_put_variable_name(nsType,index,name) return True @@ -1419,7 +1419,7 @@ class exodus: """ ssids = self.get_side_set_ids() if ( id not in ssids ): - print "WARNING: queried side set ID does not exist in database" + print("WARNING: queried side set ID does not exist in database") return 0 (num_side_in_set,num_dist_fact_in_set) = self.__ex_get_side_set_param(id) return num_side_in_set @@ -1597,9 +1597,9 @@ class exodus: ssType = ex_entity_type("EX_SIDE_SET") SSvarNames = self.get_side_set_variable_names() if name in SSvarNames: - print "WARNING:Side set variable \"", name, "\" already exists." + print("WARNING:Side set variable \"", name, "\" already exists.") if index > len(SSvarNames): - raise Exception, ("ERROR: variable index out of range.") + raise Exception(("ERROR: variable index out of range.")) self.__ex_put_variable_name(ssType,index,name) return True @@ -1708,10 +1708,10 @@ class exodus: gbType = ex_entity_type("EX_GLOBAL") GlobVarNames = self.get_global_variable_names() if name in GlobVarNames: - print "WARNING: global variable \"", name, "\" already exists." + print("WARNING: global variable \"", name, "\" already exists.") if index > len(GlobVarNames): - print "index", index, "len", len(GlobVarNames) - raise Exception, ("ERROR: variable index out of range.") + print("index", index, "len", len(GlobVarNames)) + raise Exception(("ERROR: variable index out of range.")) self.__ex_put_variable_name(gbType,index,name) return True @@ -1740,7 +1740,7 @@ class exodus: num = self.__ex_get_variable_param(gbType) gvalues = self.__ex_get_var(step,gbType,0,1,num.value) values = [] - for i in xrange(num.value): + for i in range(num.value): values.append(gvalues[i]) if self.use_numpy: values = self.np.array(values) @@ -1758,7 +1758,7 @@ class exodus: # get all values numVals = self.get_global_variable_number() values = (c_double * numVals)() - for i in xrange(numVals): + for i in range(numVals): values[i] = c_double(self.get_global_variable_value(names[i], step)) # adjust one of them values[names.index(name)] = c_double(value) @@ -1778,7 +1778,7 @@ class exodus: """ numVals = self.get_global_variable_number() gvalues = (c_double * numVals)() - for i in xrange(numVals): + for i in range(numVals): gvalues[i] = c_double(values[i]) EXODUS_LIB.ex_put_glob_vars(self.fileId, c_int(step), @@ -1811,10 +1811,10 @@ class exodus: """ e.close() -> close the exodus file. """ - print "Closing exodus file: " + self.fileName + print("Closing exodus file: " + self.fileName) errorInt = EXODUS_LIB.ex_close(self.fileId) if errorInt != 0: - raise Exception, ("ERROR: Closing file " + self.fileName + " had problems.") + raise Exception("ERROR: Closing file " + self.fileName + " had problems.") # -------------------------------------------------------------------- # @@ -1823,16 +1823,16 @@ class exodus: # -------------------------------------------------------------------- def __open(self, io_size=0): - print "Opening exodus file: " + self.fileName + print("Opening exodus file: " + self.fileName) self.mode = EX_READ if self.modeChar.lower() == "a": self.mode = EX_WRITE if self.modeChar.lower() in ["a","r"] and not os.path.isfile(self.fileName): - raise Exception, ("ERROR: Cannot open " + self.fileName + " for read. Does not exist.") + raise Exception("ERROR: Cannot open " + self.fileName + " for read. Does not exist.") elif self.modeChar.lower() == "w" and os.path.isfile(self.fileName): - raise Exception, ("ERROR: Cowardly not opening " + self.fileName + \ + raise Exception("ERROR: Cowardly not opening " + self.fileName + \ " for write. File already exists.") elif self.modeChar.lower() not in ["a","r","w"]: - raise Exception, ("ERROR: File open mode " + self.modeChar + " unrecognized.") + raise Exception("ERROR: File open mode " + self.modeChar + " unrecognized.") self.comp_ws = c_int(8) self.io_ws = c_int(io_size) self.version = c_float(0.0) @@ -1986,8 +1986,8 @@ class exodus: info_recs.append(irp.contents.value) for rec in info_recs: if len(rec) > MAX_LINE_LENGTH: - print "WARNING: max line length reached for one or more info records;" - print " info might be incomplete for these records" + print("WARNING: max line length reached for one or more info records;") + print(" info might be incomplete for these records") break return info_recs @@ -2014,7 +2014,7 @@ class exodus: dummy_int = c_int(0) val = EXODUS_LIB.ex_inquire(self.fileId,id,byref(dummy_int),byref(ret_float),dummy_char) if val < 0: - raise Exception, ("ERROR: ex_inquire(" + str(id) + ") failed on " + self.fileName) + raise Exception("ERROR: ex_inquire(" + str(id) + ") failed on " + self.fileName) return ret_float # -------------------------------------------------------------------- @@ -2023,7 +2023,7 @@ class exodus: val = c_longlong(0) val = EXODUS_LIB.ex_inquire_int(self.fileId,id) if val < 0: - raise Exception, ("ERROR: ex_inquire_int(" + str(id) + ") failed on " + self.fileName) + raise Exception("ERROR: ex_inquire_int(" + str(id) + ") failed on " + self.fileName) return val # -------------------------------------------------------------------- @@ -2248,7 +2248,7 @@ class exodus: num_blks = c_int(len(self.nodeSetIds)) num_vars = self.__ex_get_var_param("m") truth_tab = (c_int * (num_blks.value*num_vars.value))() - for i in xrange(len(truthTab)): + for i in range(len(truthTab)): boolVal = truthTab[i] if boolVal: truth_tab[i] = c_int(1) @@ -2315,7 +2315,7 @@ class exodus: id_map = (c_int * numObjs)() EXODUS_LIB.ex_get_id_map(self.fileId,obj_type,byref(id_map)) idMap = [] - for i in xrange(numObjs): + for i in range(numObjs): idMap.append(id_map[i]) return idMap @@ -2329,11 +2329,11 @@ class exodus: id_map = [] if (EXODUS_LIB.ex_int64_status(self.fileId) & EX_IDS_INT64_API): id_map = (c_longlong * numObjs)() - for i in xrange(numObjs): + for i in range(numObjs): id_map[i] = c_longlong( map[i] ) else: id_map = (c_int * numObjs)() - for i in xrange(numObjs): + for i in range(numObjs): id_map[i] = c_int( map[i] ) EXODUS_LIB.ex_put_id_map(self.fileId,obj_type,byref(id_map)) return True @@ -2491,7 +2491,7 @@ class exodus: num_blks = c_int(len(self.elemBlkIds)) num_vars = self.__ex_get_var_param("e") truth_tab = (c_int * (num_blks.value*num_vars.value))() - for i in xrange(len(truthTab)): + for i in range(len(truthTab)): boolVal = truthTab[i] if boolVal: truth_tab[i] = c_int(1) @@ -2623,7 +2623,7 @@ class exodus: num_blks = c_int(len(self.sideSetIds)) num_vars = self.__ex_get_var_param("s") truth_tab = (c_int * (num_blks.value*num_vars.value))() - for i in xrange(len(truthTab)): + for i in range(len(truthTab)): boolVal = truthTab[i] if boolVal: truth_tab[i] = c_int(1) @@ -2712,8 +2712,8 @@ class exodus: return True errorInt = EXODUS_LIB.ex_put_variable_param(self.fileId,var_type,num_vars) if errorInt != 0: - print "ERROR code =", errorInt - raise Exception, ("ERROR: ex_put_variable_param had problems. This can only be called once per varType.") + print("ERROR code =", errorInt) + raise Exception(("ERROR: ex_put_variable_param had problems. This can only be called once per varType.")) return True # -------------------------------------------------------------------- @@ -2821,9 +2821,9 @@ def collectElemConnectivity(exodusHandle,connectivity): """ if type(connectivity) is not list: - raise Exception, ("ERROR: connectivity is not a list in call to collectElemConnectivity().") + raise Exception(("ERROR: connectivity is not a list in call to collectElemConnectivity().")) if connectivity: - raise Exception, ("ERROR: connectivity is not empty in call to collectElemConnectivity().") + raise Exception(("ERROR: connectivity is not empty in call to collectElemConnectivity().")) blockIds = exodusHandle.get_elem_blk_ids() for blId in blockIds: @@ -2852,11 +2852,11 @@ def collectLocalNodeToLocalElems(exodusHandle,connectivity,localNodeToLocalElems """ if type(connectivity) is not list: - raise Exception, ("ERROR: connectivity is not a list in call to collectLocalNodeToLocalElems().") + raise Exception(("ERROR: connectivity is not a list in call to collectLocalNodeToLocalElems().")) if type(localNodeToLocalElems) is not list: - raise Exception, ("ERROR: localNodeToLocalElems is not a list in call to collectLocalNodeToLocalElems().") + raise Exception(("ERROR: localNodeToLocalElems is not a list in call to collectLocalNodeToLocalElems().")) if localNodeToLocalElems: - raise Exception, ("ERROR: localNodeToLocalElems is not empty in call to collectLocalNodeToLocalElems().") + raise Exception(("ERROR: localNodeToLocalElems is not empty in call to collectLocalNodeToLocalElems().")) if not connectivity: collectElemConnectivity(exodusHandle,connectivity) @@ -2889,13 +2889,13 @@ def collectLocalElemToLocalElems(exodusHandle,connectivity,localNodeToLocalElems """ if type(connectivity) is not list: - raise Exception, ("ERROR: connectivity is not a list in call to collectLocalElemToLocalElems().") + raise Exception(("ERROR: connectivity is not a list in call to collectLocalElemToLocalElems().")) if type(localNodeToLocalElems) is not list: - raise Exception, ("ERROR: localNodeToLocalElems is not a list in call to collectLocalElemToLocalElems().") + raise Exception(("ERROR: localNodeToLocalElems is not a list in call to collectLocalElemToLocalElems().")) if type(localElemToLocalElems) is not list: - raise Exception, ("ERROR: localElemToLocalElems is not a list in call to collectLocalElemToLocalElems().") + raise Exception(("ERROR: localElemToLocalElems is not a list in call to collectLocalElemToLocalElems().")) if localElemToLocalElems: - raise Exception, ("ERROR: localElemToLocalElems is not empty in call to collectLocalElemToLocalElems().") + raise Exception(("ERROR: localElemToLocalElems is not empty in call to collectLocalElemToLocalElems().")) if not connectivity: collectElemConnectivity(exodusHandle,connectivity) @@ -2932,7 +2932,7 @@ def copy_mesh(fromFileName, toFileName, exoFromObj = None, array_type = 'ctype') exoFrom = exoFromObj if ( os.path.isfile(toFileName) ): - raise Exception, ("ERROR: ", toFileName, " file already exists cowardly exiting instead of overwriting in call to copy_mesh().") + raise Exception("ERROR: ", toFileName, " file already exists cowardly exiting instead of overwriting in call to copy_mesh().") title = exoFrom.title() numDim = exoFrom.num_dimensions() @@ -2947,20 +2947,20 @@ def copy_mesh(fromFileName, toFileName, exoFromObj = None, array_type = 'ctype') numNodes = numNodes, numElems = numElems, numBlocks = numBlks, \ numNodeSets = numNodeSets, numSideSets = numSideSets ) - if debugPrint: print "Transfer QA records" + if debugPrint: print("Transfer QA records") qaRecords = exoFrom.get_qa_records() exoTo.put_qa_records( qaRecords ) - if debugPrint: print "Transfer Nodal Coordinates and Names" + if debugPrint: print("Transfer Nodal Coordinates and Names") exoTo.put_coord_names( exoFrom.get_coord_names() ) (xCoords,yCoords,zCoords) = exoFrom.get_coords() exoTo.put_coords(xCoords,yCoords,zCoords) - if debugPrint: print "Transfer Node Id Map" + if debugPrint: print("Transfer Node Id Map") nodeIdMap = exoFrom.get_node_id_map() exoTo.put_node_id_map(nodeIdMap) - if debugPrint: print "Transfer Element Data" + if debugPrint: print("Transfer Element Data") blkIds = exoFrom.get_elem_blk_ids() for blkId in blkIds: (elemType,numElem,nodesPerElem,numAttr) = exoFrom.elem_blk_info(blkId) @@ -2981,11 +2981,11 @@ def copy_mesh(fromFileName, toFileName, exoFromObj = None, array_type = 'ctype') blockName = exoFrom.get_elem_blk_name(blkId) exoTo.put_elem_blk_name(blkId,blockName) - if debugPrint: print "Transfer Element Id Map" + if debugPrint: print("Transfer Element Id Map") elemIdMap = exoFrom.get_elem_id_map() exoTo.put_elem_id_map(elemIdMap) - if debugPrint: print "Transfer Node Sets" + if debugPrint: print("Transfer Node Sets") if numNodeSets > 0: nodeSetIds = exoFrom.get_node_set_ids() for nsId in nodeSetIds: @@ -3006,7 +3006,7 @@ def copy_mesh(fromFileName, toFileName, exoFromObj = None, array_type = 'ctype') else: exoTo.put_node_set_property_value(nsId,nodeSetProp,propVal) - if debugPrint: print "Transfer Side Sets" + if debugPrint: print("Transfer Side Sets") if numSideSets > 0: sideSetIds = exoFrom.get_side_set_ids() for ssId in sideSetIds: @@ -3062,37 +3062,37 @@ def transfer_variables(exoFrom, exoTo, array_type = 'ctype', debugPrint = False if type(additionalGlobalVariables) is not list: - raise Exception, ("ERROR: additionalGlobalVariables is not a list.") + raise Exception(("ERROR: additionalGlobalVariables is not a list.")) if type(additionalNodalVariables) is not list: - raise Exception, ("ERROR: additionalNodalVariables is not a list.") + raise Exception(("ERROR: additionalNodalVariables is not a list.")) if type(additionalElementVariables) is not list: - raise Exception, ("ERROR: additionalElementVariables is not a list.") + raise Exception(("ERROR: additionalElementVariables is not a list.")) - if debugPrint: print "Transfer Info records" + if debugPrint: print("Transfer Info records") numInfoRecs = exoFrom.num_info_records() if numInfoRecs > 0: infoRecs = exoFrom.get_info_records() exoTo.put_info_records( infoRecs ) - if debugPrint: print "Transfer time values" + if debugPrint: print("Transfer time values") nSteps = exoFrom.num_times() timeVals = exoFrom.get_times() - for step in xrange(nSteps): + for step in range(nSteps): exoTo.put_time( step+1, timeVals[step] ) - if debugPrint: print "Add Global Variables" + if debugPrint: print("Add Global Variables") nNewGlobalVars = len(additionalGlobalVariables) nGlobalVars = exoFrom.get_global_variable_number() + nNewGlobalVars defaultNewVarVals = [] - for i in xrange(nNewGlobalVars): + for i in range(nNewGlobalVars): defaultNewVarVals.append(0.0) if nGlobalVars > 0: exoTo.set_global_variable_number(nGlobalVars) gVarNames = exoFrom.get_global_variable_names() gVarNames.extend( additionalGlobalVariables ) - for nameIndex in xrange(nGlobalVars): + for nameIndex in range(nGlobalVars): globalVarName = gVarNames[nameIndex] exoTo.put_global_variable_name(globalVarName,nameIndex+1) - for step in xrange(nSteps): + for step in range(nSteps): gValues = exoFrom.get_all_global_variable_values(step+1) if array_type == 'numpy': gValues = exoTo.np.append(gValues, defaultNewVarVals) @@ -3100,7 +3100,7 @@ def transfer_variables(exoFrom, exoTo, array_type = 'ctype', gValues.extend( defaultNewVarVals ) exoTo.put_all_global_variable_values(step+1,gValues) - if debugPrint: print "Add Nodal Variables" + if debugPrint: print("Add Nodal Variables") nNewNodalVars = len(additionalNodalVariables) nOrigNodalVars = exoFrom.get_node_variable_number() nNodalVars = nOrigNodalVars + nNewNodalVars @@ -3108,15 +3108,15 @@ def transfer_variables(exoFrom, exoTo, array_type = 'ctype', exoTo.set_node_variable_number(nNodalVars) nVarNames = exoFrom.get_node_variable_names() nVarNames.extend( additionalNodalVariables ) - for nameIndex in xrange(nNodalVars): + for nameIndex in range(nNodalVars): nodalVarName = nVarNames[nameIndex] exoTo.put_node_variable_name(nodalVarName,nameIndex+1) if nameIndex < nOrigNodalVars: - for step in xrange(nSteps): + for step in range(nSteps): nValues = exoFrom.get_node_variable_values(nodalVarName,step+1) exoTo.put_node_variable_values(nodalVarName,step+1,nValues) - if debugPrint: print "Construct Truth Table for additionalElementVariables" + if debugPrint: print("Construct Truth Table for additionalElementVariables") blkIds = exoFrom.get_elem_blk_ids() numBlks = exoFrom.num_blks() newElemVariableNames = [] @@ -3133,10 +3133,10 @@ def transfer_variables(exoFrom, exoTo, array_type = 'ctype', newElemVariableNames.append( item ) newElemVariableBlocks.append( blkIds ) else: - print "Warning additionalElementVariable item ", item, " is not right type to add." - print "should be a string or tuple, skipping" + print("Warning additionalElementVariable item ", item, " is not right type to add.") + print("should be a string or tuple, skipping") - if debugPrint: print "Add Element Variables" + if debugPrint: print("Add Element Variables") nNewElemVars = len(newElemVariableNames) nOrigElemVars = exoFrom.get_element_variable_number() nElemVars = nOrigElemVars + nNewElemVars @@ -3150,25 +3150,25 @@ def transfer_variables(exoFrom, exoTo, array_type = 'ctype', truthTable = exoFrom.get_element_variable_truth_table() if nNewElemVars > 0: newTruth = [] - for j in xrange(numBlks): - for k in xrange(nOrigElemVars): + for j in range(numBlks): + for k in range(nOrigElemVars): index = j*nOrigElemVars + k newTruth.append( truthTable[index] ) - for m in xrange(nNewElemVars): + for m in range(nNewElemVars): if blkIds[j] in newElemVariableBlocks[m]: newTruth.append(True) else: newTruth.append(False) truthTable = newTruth exoTo.set_element_variable_truth_table(truthTable) - for nameIndex in xrange(nElemVars): + for nameIndex in range(nElemVars): elemVarName = eVarNames[nameIndex] exoTo.put_element_variable_name(elemVarName,nameIndex+1) truthIndex = 0 for blkId in blkIds: for eVarName in origElemVarNames: if truthTable[truthIndex]: - for step in xrange(nSteps): + for step in range(nSteps): eValues = exoFrom.get_element_variable_values(blkId,eVarName,step+1) exoTo.put_element_variable_values(blkId,eVarName,step+1,eValues) truthIndex = truthIndex + 1 @@ -3199,16 +3199,16 @@ def add_variables(exo, global_vars = [], nodal_vars = [], element_vars = [], \ debugPrint = False if type(global_vars) is not list: - raise Exception, ("ERROR: global_vars is not a list.") + raise Exception(("ERROR: global_vars is not a list.")) if type(nodal_vars) is not list: - raise Exception, ("ERROR: nodal_vars is not a list.") + raise Exception(("ERROR: nodal_vars is not a list.")) if type(element_vars) is not list: - raise Exception, ("ERROR: element_vars is not a list.") + raise Exception(("ERROR: element_vars is not a list.")) if exo.modeChar is 'r': - raise Exception, ("ERROR: variables cannot be added to an exodus object in read only mode") + raise Exception(("ERROR: variables cannot be added to an exodus object in read only mode")) - if debugPrint: print "Add Global Variables" + if debugPrint: print("Add Global Variables") n_new_vars = len(global_vars) n_old_vars = exo.get_global_variable_number() n_vars = n_old_vars + n_new_vars @@ -3222,7 +3222,7 @@ def add_variables(exo, global_vars = [], nodal_vars = [], element_vars = [], \ #all the global variables for a given step and then putting them all back #in, so we might as well just use exo.put_all_global_variable_values(). nSteps = exo.num_times() - for step in xrange(nSteps): + for step in range(nSteps): gValues = exo.get_all_global_variable_values(step+1) if array_type == 'numpy': gValues = exo.np.append(gValues, default_vals) @@ -3230,7 +3230,7 @@ def add_variables(exo, global_vars = [], nodal_vars = [], element_vars = [], \ gValues.extend( default_vals ) exo.put_all_global_variable_values(step+1, gValues) - if debugPrint: print "Add Nodal Variables" + if debugPrint: print("Add Nodal Variables") n_new_vars = len(nodal_vars) n_old_vars = exo.get_node_variable_number() n_vars = n_old_vars + n_new_vars @@ -3239,7 +3239,7 @@ def add_variables(exo, global_vars = [], nodal_vars = [], element_vars = [], \ for i, var_name in enumerate(nodal_vars): exo.put_node_variable_name(var_name, i + n_old_vars + 1) - if debugPrint: print "Construct Truth Table for additionalElementVariables" + if debugPrint: print("Construct Truth Table for additionalElementVariables") new_e_var_names = [] new_e_var_blks = [] blk_ids = exo.get_elem_blk_ids() @@ -3255,10 +3255,10 @@ def add_variables(exo, global_vars = [], nodal_vars = [], element_vars = [], \ new_e_var_names.append( item ) new_e_var_blks.append( blk_ids ) else: - print "Warning additionalElementVariable item ", item, " is not right type to add." - print "should be a string or tuple, skipping" + print("Warning additionalElementVariable item ", item, " is not right type to add.") + print("should be a string or tuple, skipping") - if debugPrint: print "Add Element Variables" + if debugPrint: print("Add Element Variables") n_new_vars = len(new_e_var_names) n_old_vars = exo.get_element_variable_number() n_vars = n_old_vars + n_new_vars @@ -3269,11 +3269,11 @@ def add_variables(exo, global_vars = [], nodal_vars = [], element_vars = [], \ old_truth_table = exo.get_element_variable_truth_table() truth_table = [] n_blks = exo.num_blks() - for j in xrange(n_blks): - for k in xrange(n_old_vars): + for j in range(n_blks): + for k in range(n_old_vars): ndx = j * n_old_vars + k truth_table.append( old_truth_table[ndx] ) - for m in xrange(n_new_vars): + for m in range(n_new_vars): if blk_ids[j] in new_e_var_blks[m]: truth_table.append(True) else: -- 2.24.1