mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Make many scripts in src/utils Python 3 compatible.
This commit is contained in:
parent
b102b71809
commit
f7f61bb575
10 changed files with 49 additions and 31 deletions
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
@ -36,7 +38,7 @@ for sourceFile in source:
|
|||
commentChar = '!'
|
||||
elif ending == 'F90':
|
||||
commentChar = '!'
|
||||
|
||||
|
||||
for line in open(sourceFile, 'r'):
|
||||
line = line.strip()
|
||||
if line.startswith(commentChar):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import glob
|
||||
import re
|
||||
|
|
@ -18,7 +20,6 @@ for src in glob.iglob('*.F90'):
|
|||
if deps:
|
||||
dependencies[module] = sorted(list(deps))
|
||||
|
||||
|
||||
for module in sorted(dependencies.keys()):
|
||||
for dep in dependencies[module]:
|
||||
print("{0}.o: {1}.o".format(module, dep))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
#!/usr/bin/python2
|
||||
# Filename: eigenfunction_rms.py
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# import packages
|
||||
import statepoint
|
||||
import numpy as np
|
||||
import os
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
||||
import statepoint
|
||||
|
||||
def main(tally_id, score_id, batch_start, batch_end, name):
|
||||
|
||||
# read in statepoint header data
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This script reads a cross_sections.out file, adds up the memory usage for
|
||||
# each nuclide and S(a,b) table, and displays the total memory usage
|
||||
"""
|
||||
This script reads a cross_sections.out file, adds up the memory usage for each
|
||||
nuclide and S(a,b) table, and displays the total memory usage.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""Python script to plot tally data generated by OpenMC."""
|
||||
|
||||
|
|
@ -15,12 +15,16 @@ from statepoint import *
|
|||
|
||||
if sys.version_info[0] < 3:
|
||||
import Tkinter as tk
|
||||
import tkFileDialog as filedialog
|
||||
import tkFont as font
|
||||
import tkMessageBox as messagebox
|
||||
import ttk as ttk
|
||||
else:
|
||||
import tkinter as tk
|
||||
import tkFileDialog
|
||||
import tkFont
|
||||
import tkMessageBox
|
||||
import ttk
|
||||
import tkinter.filedialog as filedialog
|
||||
import tkinter.font as font
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.ttk as ttk
|
||||
|
||||
|
||||
class MeshPlotter(tk.Frame):
|
||||
|
|
@ -111,8 +115,9 @@ class MeshPlotter(tk.Frame):
|
|||
self.scoreBox.bind('<<ComboboxSelected>>', self.redraw)
|
||||
|
||||
# Filter label
|
||||
font = tkFont.Font(weight='bold')
|
||||
labelFilters = tk.Label(self.selectFrame, text='Filters:', font=font)
|
||||
boldfont = font.Font(weight='bold')
|
||||
labelFilters = tk.Label(self.selectFrame, text='Filters:',
|
||||
font=boldfont)
|
||||
labelFilters.grid(row=5, column=0, sticky=tk.W)
|
||||
|
||||
def update(self, event=None):
|
||||
|
|
@ -201,7 +206,7 @@ class MeshPlotter(tk.Frame):
|
|||
|
||||
# Create spec_list
|
||||
spec_list = []
|
||||
for f in selectedTally.filters.values():
|
||||
for f in list(selectedTally.filters.values()):
|
||||
if f.type == 'mesh':
|
||||
continue
|
||||
index = self.filterBoxes[f.type].current()
|
||||
|
|
@ -296,8 +301,8 @@ class MeshPlotter(tk.Frame):
|
|||
self.meshTallies.append(itally)
|
||||
|
||||
if not self.meshTallies:
|
||||
tkMessageBox.showerror("Invalid StatePoint File",
|
||||
"File does not contain mesh tallies!")
|
||||
messagebox.showerror("Invalid StatePoint File",
|
||||
"File does not contain mesh tallies!")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
@ -308,16 +313,16 @@ if __name__ == '__main__':
|
|||
|
||||
# If no filename given as command-line argument, open file dialog
|
||||
if len(sys.argv) < 2:
|
||||
filename = tkFileDialog.askopenfilename(title='Select statepoint file',
|
||||
initialdir='.')
|
||||
filename = filedialog.askopenfilename(title='Select statepoint file',
|
||||
initialdir='.')
|
||||
else:
|
||||
filename = sys.argv[1]
|
||||
|
||||
if filename:
|
||||
# Check to make sure file exists
|
||||
if not os.path.isfile(filename):
|
||||
tkMessageBox.showerror("File not found",
|
||||
"Could not find regular file: " + filename)
|
||||
messagebox.showerror("File not found",
|
||||
"Could not find regular file: " + filename)
|
||||
sys.exit(1)
|
||||
|
||||
app = MeshPlotter(root, filename)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
from sys import argv
|
||||
from math import sqrt
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This program takes OpenMC statepoint binary files and creates a variety of
|
||||
# outputs from them which should provide the user with an idea of the
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
# fileType, printxs, showImg, and savetoCSV. See the options block for more
|
||||
# information.
|
||||
|
||||
from __future__ import print_function
|
||||
from math import sqrt, pow
|
||||
from glob import glob
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue