Merge pull request #812 from paulromano/verbosity

Improved use of verbosity
This commit is contained in:
Adam Nelson 2017-03-03 05:06:40 -05:00 committed by GitHub
commit 7927a2d814
21 changed files with 196 additions and 189 deletions

File diff suppressed because one or more lines are too long

View file

@ -839,17 +839,27 @@ problem. It has the following attributes/sub-elements:
*Default*: None
.. _verbosity:
``<verbosity>`` Element
-----------------------
The ``<verbosity>`` element tells the code how much information to display to
the standard output. A higher verbosity corresponds to more information being
displayed. This element takes the following attributes:
displayed. The text of this element should be an integer between between 1
and 10. The verbosity levels are defined as follows:
:value:
The specified verbosity between 1 and 10.
:1: don't display any output
:2: only show OpenMC logo
:3: all of the above + headers
:4: all of the above + results
:5: all of the above + file I/O
:6: all of the above + timing statistics and initialization messages
:7: all of the above + :math:`k` by generation
:9: all of the above + indicate when each particle starts
:10: all of the above + event information
*Default*: 5
*Default*: 7
``<create_fission_neutrons>`` Element
-------------------------------------

View file

@ -1,3 +1,5 @@
import warnings
from openmc.arithmetic import *
from openmc.cell import *
from openmc.mesh import *
@ -28,6 +30,9 @@ from openmc.mixin import *
from openmc.plotter import *
try:
from openmc.openmoc_compatible import *
# Ignore matplotlib warning caused by OpenMOC calling matplotlib.use()
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from openmc.openmoc_compatible import *
except ImportError:
pass

View file

@ -6,16 +6,12 @@ from six import string_types
from openmc import VolumeCalculation
_summary_indicator = "TIMING STATISTICS"
def _run(args, output, cwd):
# Launch a subprocess
p = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, universal_newlines=True)
storage_flag = False
# Capture and re-print OpenMC output in real-time
while True:
# If OpenMC is finished, break loop
@ -23,17 +19,9 @@ def _run(args, output, cwd):
if not line and p.poll() is not None:
break
if output == 'full':
if output:
# If user requested output, print to screen
print(line, end='')
elif output == 'summary' and _summary_indicator in line:
# If they requested a summary, look for the start of the summary
storage_flag = True
if storage_flag:
# If a summary is requested, and we have reached the summary,
# then print it
print(line, end='')
# Return the returncode (integer, zero if no problems encountered)
return p.returncode
@ -52,8 +40,6 @@ def plot_geometry(output=True, openmc_exec='openmc', cwd='.'):
Path to working directory to run in. Defaults to the current working directory.
"""
if output:
output = 'full'
return _run([openmc_exec, '-p'], output, cwd)
@ -102,13 +88,11 @@ def calculate_volumes(threads=None, output=True, cwd='.',
if mpi_args is not None:
args = mpi_args + args
if output:
output = 'full'
return _run(args, output, cwd)
def run(particles=None, threads=None, geometry_debug=False,
restart_file=None, tracks=False, output='full', cwd='.',
restart_file=None, tracks=False, output=True, cwd='.',
openmc_exec='openmc', mpi_args=None):
"""Run an OpenMC simulation.
@ -127,10 +111,8 @@ def run(particles=None, threads=None, geometry_debug=False,
Path to restart file to use
tracks : bool, optional
Write tracks for all particles. Defaults to False.
output : {"full", "summary", "none", False}, optional
Degree of OpenMC output captured from standard out. "full" prints all
output; "summary" prints only the results summary, and "none" or False
does not show the output. Defaults to "full".
output : bool
Capture OpenMC output from standard out
cwd : str, optional
Path to working directory to run in. Defaults to the current working
directory.

View file

@ -142,7 +142,8 @@ class Settings(object):
Mesh to be used for redistributing source sites via the uniform fision
site (UFS) method.
verbosity : int
Verbosity during simulation between 1 and 10
Verbosity during simulation between 1 and 10. Verbosity levels are
described in :ref:`verbosity`.
volume_calculations : VolumeCalculation or iterable of VolumeCalculation
Stochastic volume calculation specifications

View file

@ -782,7 +782,7 @@ contains
! write that dhats are zero
if (dhat_reset) then
call write_message('Dhats reset to zero.', 1)
call write_message('Dhats reset to zero.', 8)
end if
end subroutine compute_dhat

View file

@ -363,7 +363,7 @@ contains
integer :: i ! loop counter
! Print message
call write_message("CMFD tallies reset", 7)
call write_message("CMFD tallies reset", 6)
! Reset CMFD tallies
do i = 1, size(cmfd_tallies)

View file

@ -1011,7 +1011,7 @@ contains
type(VectorInt), allocatable :: neighbor_neg(:)
call write_message("Building neighboring cells lists for each surface...", &
4)
6)
allocate(neighbor_pos(n_surfaces))
allocate(neighbor_neg(n_surfaces))

View file

@ -24,8 +24,8 @@ module initialize
use material_header, only: Material
use message_passing
use mgxs_data, only: read_mgxs, create_macro_xs
use output, only: title, header, print_version, write_message, &
print_usage, print_plot
use output, only: print_version, write_message, print_usage, &
print_plot
use random_lcg, only: initialize_prng
use state_point, only: load_state_point
use string, only: to_str, starts_with, ends_with, str_to_int
@ -68,12 +68,6 @@ contains
! Read command line arguments
call read_command_line()
if (master) then
! Display title and initialization header
call title()
call header("INITIALIZATION", level=1)
end if
! Read XML input files
call read_input_xml()
@ -137,7 +131,7 @@ contains
if (master) then
if (run_mode == MODE_PLOTTING) then
! Display plotting information
call print_plot()
if (verbosity >= 5) call print_plot()
else
! Write summary information
if (output_summary) call write_summary()
@ -148,9 +142,8 @@ contains
if (particle_restart_run) run_mode = MODE_PARTICLE
! Warn if overlap checking is on
if (master .and. check_overlaps) then
call write_message("")
call warning("Cell overlap checking is ON")
if (master .and. check_overlaps .and. run_mode /= MODE_PLOTTING) then
call warning("Cell overlap checking is ON.")
end if
! Stop initialization timer

View file

@ -18,7 +18,7 @@ module input_xml
use message_passing
use mgxs_data, only: create_macro_xs, read_mgxs
use multipole, only: multipole_read
use output, only: write_message
use output, only: write_message, title, header
use plot_header
use random_lcg, only: prn, seed
use surface_header
@ -119,13 +119,23 @@ contains
! The settings.xml file is optional if we just want to make a plot.
return
end if
else
call write_message("Reading settings XML file...", 5)
end if
! Parse settings.xml file
call open_xmldoc(doc, filename)
! Verbosity
if (check_for_node(doc, "verbosity")) then
call get_node_value(doc, "verbosity", verbosity)
end if
! To this point, we haven't displayed any output since we didn't know what
! the verbosity is. Now that we checked for it, show the title if necessary
if (master) then
if (verbosity >= 2) call title()
end if
call write_message("Reading settings XML file...", 5)
! Find if a multi-group or continuous-energy simulation is desired
if (check_for_node(doc, "energy_mode")) then
call get_node_value(doc, "energy_mode", temp_str)
@ -294,12 +304,6 @@ contains
n_log_bins = 8000
end if
! Verbosity
if (check_for_node(doc, "verbosity")) then
call get_node_ptr(doc, "verbosity", node_verb)
call get_node_value(node_verb, "value", verbosity)
end if
! Number of OpenMP threads
if (check_for_node(doc, "threads")) then
#ifdef _OPENMP
@ -5214,7 +5218,7 @@ contains
== energy_max_neutron) then
call write_message("Maximum neutron transport energy: " // &
trim(to_str(energy_max_neutron)) // " eV for " // &
trim(adjustl(nuclides(i) % name)), 6)
trim(adjustl(nuclides(i) % name)), 7)
exit
end if
end do

View file

@ -43,10 +43,10 @@ contains
! Could not find MGXS Library file
call fatal_error("Cross sections HDF5 file '" &
&// trim(path_cross_sections) // "' does not exist!")
// trim(path_cross_sections) // "' does not exist!")
end if
call write_message("Loading Cross Section Data...", 5)
call write_message("Loading cross section data...", 5)
! Get temperatures
call get_temperatures(cells, materials, material_dict, nuclide_dict, &
@ -75,7 +75,7 @@ contains
i_xsdata = xsdata_dict % get_key(to_lower(name))
i_nuclide = mat % nuclide(j)
call write_message("Loading " // trim(name) // " Data...", 5)
call write_message("Loading " // trim(name) // " data...", 6)
! Check to make sure cross section set exists in the library
if (object_exists(file_id, trim(name))) then

View file

@ -91,6 +91,7 @@ contains
write(UNIT=OUTPUT_UNIT, FMT='(4X,"OpenMP Threads | ",A)') &
trim(to_str(omp_get_max_threads()))
#endif
write(UNIT=OUTPUT_UNIT, FMT=*)
end subroutine title
@ -112,27 +113,19 @@ contains
!===============================================================================
! HEADER displays a header block according to a specified level. If no level is
! specified, it is assumed to be a minor header block (H3).
! specified, it is assumed to be a minor header block.
!===============================================================================
subroutine header(msg, unit, level)
subroutine header(msg, level, unit)
character(*), intent(in) :: msg ! header message
integer, intent(in) :: level
integer, intent(in), optional :: unit ! unit to write to
integer, intent(in), optional :: level ! specified header level
integer :: n ! number of = signs on left
integer :: m ! number of = signs on right
integer :: unit_ ! unit to write to
integer :: header_level ! actual header level
character(MAX_LINE_LEN) :: line
! set default level
if (present(level)) then
header_level = level
else
header_level = 3
end if
! set default unit
if (present(unit)) then
unit_ = unit
@ -149,17 +142,10 @@ contains
line = to_upper(msg)
! print header based on level
select case (header_level)
case (1)
write(UNIT=unit_, FMT='(/3(1X,A/))') repeat('=', 75), &
repeat('=', n) // '> ' // trim(line) // ' <' // &
repeat('=', m), repeat('=', 75)
case (2)
write(UNIT=unit_, FMT='(/2(1X,A/))') trim(line), repeat('-', 75)
case (3)
if (verbosity >= level) then
write(UNIT=unit_, FMT='(/1X,A/)') repeat('=', n) // '> ' // &
trim(line) // ' <' // repeat('=', m)
end select
end if
end subroutine header
@ -460,7 +446,7 @@ contains
type(ObjectPlot), pointer :: pl
! Display header for plotting
call header("PLOTTING SUMMARY")
call header("PLOTTING SUMMARY", 5)
do i = 1, n_plots
pl => plots(i)
@ -535,7 +521,7 @@ contains
character(15) :: string
! display header block
call header("Timing Statistics")
call header("Timing Statistics", 6)
! display time elapsed for various sections
write(ou,100) "Total time for initialization", time_initialize % elapsed
@ -608,7 +594,7 @@ contains
real(8) :: t_value ! t-value for confidence intervals
! display header block for results
call header("Results")
call header("Results", 4)
if (confidence_intervals) then
! Calculate t-value for confidence intervals
@ -666,7 +652,7 @@ contains
integer :: num_sparse = 0
! display header block for geometry debugging section
call header("Cell Overlap Check Summary")
call header("Cell Overlap Check Summary", 1)
write(ou,100) 'Cell ID','No. Overlap Checks'
@ -775,11 +761,10 @@ contains
! Write header block
if (t % name == "") then
call header("TALLY " // trim(to_str(t % id)), unit=unit_tally, &
level=3)
call header("TALLY " // trim(to_str(t % id)), 1, unit=unit_tally)
else
call header("TALLY " // trim(to_str(t % id)) // ": " &
// trim(t % name), unit=unit_tally, level=3)
// trim(t % name), 1, unit=unit_tally)
endif
! Write derivative information.

View file

@ -74,7 +74,7 @@ contains
! Write meessage
call write_message("Loading particle restart file " &
&// trim(path_particle_restart) // "...", 1)
// trim(path_particle_restart) // "...", 5)
! Open file
file_id = file_open(path_particle_restart, 'r')

View file

@ -46,10 +46,10 @@ contains
! Display header
if (master) then
if (run_mode == MODE_FIXEDSOURCE) then
call header("FIXED SOURCE TRANSPORT SIMULATION", level=1)
call header("FIXED SOURCE TRANSPORT SIMULATION", 3)
elseif (run_mode == MODE_EIGENVALUE) then
call header("K EIGENVALUE SIMULATION", level=1)
call print_columns()
call header("K EIGENVALUE SIMULATION", 3)
if (verbosity >= 7) call print_columns()
end if
end if
@ -110,8 +110,6 @@ contains
! ==========================================================================
! END OF RUN WRAPUP
if (master) call header("SIMULATION FINISHED", level=1)
call finalize_simulation()
! Clear particle
@ -172,7 +170,7 @@ contains
if (run_mode == MODE_FIXEDSOURCE) then
call write_message("Simulating batch " // trim(to_str(current_batch)) &
// "...", 1)
// "...", 6)
end if
! Reset total starting particle weight used for normalizing tallies
@ -273,7 +271,8 @@ contains
call calculate_average_keff()
! Write generation output
if (master .and. current_gen /= gen_per_batch) call print_generation()
if (master .and. current_gen /= gen_per_batch .and. verbosity >= 7) &
call print_generation()
elseif (run_mode == MODE_FIXEDSOURCE) then
! For fixed-source mode, we need to sample the external source
if (path_source == '') then
@ -310,7 +309,7 @@ contains
if (cmfd_on) call execute_cmfd()
! Display output
if (master) call print_batch_keff()
if (master .and. verbosity >= 7) call print_batch_keff()
! Calculate combined estimate of k-effective
if (master) call calculate_combined_keff()
@ -356,7 +355,7 @@ contains
! Write message at beginning
if (current_batch == 1) then
call write_message("Replaying history from state point...", 1)
call write_message("Replaying history from state point...", 6)
end if
if (run_mode == MODE_EIGENVALUE) then
@ -365,17 +364,19 @@ contains
call calculate_average_keff()
! print out batch keff
if (current_gen < gen_per_batch) then
if (master) call print_generation()
else
if (master) call print_batch_keff()
if (verbosity >= 7) then
if (current_gen < gen_per_batch) then
if (master) call print_generation()
else
if (master) call print_batch_keff()
end if
end if
end do
end if
! Write message at end
if (current_batch == restart_batch) then
call write_message("Resuming simulation...", 1)
call write_message("Resuming simulation...", 6)
end if
end subroutine replay_batch_history
@ -403,8 +404,8 @@ contains
call time_finalize%stop()
call time_total%stop()
if (master) then
call print_runtime()
call print_results()
if (verbosity >= 6) call print_runtime()
if (verbosity >= 4) call print_results()
if (check_overlaps) call print_overlap_check()
end if

View file

@ -40,7 +40,7 @@ contains
character(MAX_FILE_LEN) :: filename
type(Bank), pointer :: src ! source bank site
call write_message("Initializing source particles...", 6)
call write_message("Initializing source particles...", 5)
if (path_source /= '') then
! Read the source from a binary file instead of sampling from some
@ -84,7 +84,7 @@ contains
! Write out initial source
if (write_initial_source) then
call write_message('Writing out initial source...', 1)
call write_message('Writing out initial source...', 5)
filename = trim(path_output) // 'initial_source.h5'
file_id = file_create(filename, parallel=.true.)
call write_source_bank(file_id)

View file

@ -56,7 +56,7 @@ contains
filename = trim(filename) // '.h5'
! Write message
call write_message("Creating state point " // trim(filename) // "...", 1)
call write_message("Creating state point " // trim(filename) // "...", 5)
if (master) then
! Create statepoint file
@ -440,7 +440,7 @@ contains
& zero_padded(current_batch, count_digits(n_max_batches))
filename = trim(filename) // '.h5'
call write_message("Creating source file " // trim(filename) &
// "...", 1)
// "...", 5)
! Create separate source file
if (master .or. parallel) then
@ -464,7 +464,7 @@ contains
! Also check to write source separately in overwritten file
if (source_latest) then
filename = trim(path_output) // 'source' // '.h5'
call write_message("Creating source file " // trim(filename) // "...", 1)
call write_message("Creating source file " // trim(filename) // "...", 5)
if (master .or. parallel) then
file_id = file_create(filename, parallel=.true.)
call write_dataset(file_id, "filetype", 'source')
@ -627,7 +627,7 @@ contains
! Write message
call write_message("Loading state point " // trim(path_state_point) &
// "...", 1)
// "...", 5)
! Open file for reading
file_id = file_open(path_state_point, 'r', parallel=.true.)
@ -781,7 +781,7 @@ contains
! Write message
call write_message("Loading source file " // trim(path_source_point) &
// "...", 1)
// "...", 5)
! Open source file
file_id = file_open(path_source_point, 'r', parallel=.true.)

View file

@ -46,16 +46,16 @@ contains
! When trigger threshold is reached, write information
if (satisfy_triggers) then
call write_message("Triggers satisfied for batch " // &
trim(to_str(current_batch)))
trim(to_str(current_batch)), 7)
! When trigger is not reached write convergence info for user
elseif (name == "eigenvalue") then
call write_message("Triggers unsatisfied, max unc./thresh. is " // &
trim(to_str(max_ratio)) // " for " // trim(name))
trim(to_str(max_ratio)) // " for " // trim(name), 7)
else
call write_message("Triggers unsatisfied, max unc./thresh. is " // &
trim(to_str(max_ratio)) // " for " // trim(name) // &
" in tally " // trim(to_str(tally_id)))
" in tally " // trim(to_str(tally_id)), 7)
end if
! If batch_interval is not set, estimate batches till triggers are satisfied
@ -75,7 +75,7 @@ contains
" -- greater than max batches. ")
else
call write_message("The estimated number of batches is " // &
trim(to_str(n_pred_batches)))
trim(to_str(n_pred_batches)), 7)
end if
end if
end subroutine check_triggers

View file

@ -42,7 +42,7 @@ contains
type(VectorReal), allocatable :: uncertainty_vec(:) ! uncertainty of total # of atoms
if (master) then
call header("STOCHASTIC VOLUME CALCULATION", level=1)
call header("STOCHASTIC VOLUME CALCULATION", 3)
call time_volume % start()
end if
@ -54,7 +54,7 @@ contains
if (master) then
call write_message("Running volume calculation " // trim(to_str(i)) &
// "...")
// "...", 4)
end if
call get_volume(volume_calcs(i), volume, nuclide_vec, atoms_vec, &
@ -74,9 +74,10 @@ contains
do j = 1, size(volume_calcs(i) % domain_id)
call write_message(trim(domain_type) // " " // trim(to_str(&
volume_calcs(i) % domain_id(j))) // ": " // trim(to_str(&
volume(1,j))) // " +/- " // trim(to_str(volume(2,j))) // " cm^3")
volume(1,j))) // " +/- " // trim(to_str(volume(2,j))) // &
" cm^3", 4)
end do
call write_message("")
call write_message("", 4)
filename = trim(path_output) // 'volume_' // trim(to_str(i)) // '.h5'
call write_volume(volume_calcs(i), filename, volume, nuclide_vec, &
@ -90,7 +91,7 @@ contains
if (master) then
call time_volume % stop()
call write_message("Elapsed time: " // trim(to_str(time_volume % &
get_value())) // " s")
get_value())) // " s", 6)
end if
end subroutine run_volume_calculations

View file

@ -7,9 +7,6 @@
<inactive>10</inactive>
<particles>1000</particles>
<!-- How verbose output should be -->
<verbosity value="7" />
<!-- Starting source -->
<source>
<space>

View file

@ -7,9 +7,6 @@
<inactive>10</inactive>
<particles>1000</particles>
<!-- How verbose output should be -->
<verbosity value="7" />
<!-- Starting source -->
<source>
<space>

View file

@ -1,6 +1,7 @@
<?xml version="1.0"?>
<settings>
<verbosity>1</verbosity>
<run_mode>eigenvalue</run_mode>
<batches>12</batches>
<inactive>5</inactive>