Added 'modes' to improve program logic.

This commit is contained in:
Paul Romano 2012-04-07 11:12:22 -04:00
parent 855e9c3a28
commit f4f2a85b6f
9 changed files with 32 additions and 33 deletions

View file

@ -325,9 +325,11 @@ module constants
SRC_POINT = 2, & ! Source at a single point
SRC_FILE = 3 ! Source from a file
! Running modes
integer, parameter :: &
PROB_SOURCE = 1, & ! External source problem
PROB_CRITICALITY = 2 ! Criticality problem
MODE_FIXEDSOURCE = 1, & ! Fixed source mode
MODE_CRITICALITY = 2, & ! Criticality mode
MODE_PLOTTING = 3 ! Plotting mode
! Unit numbers
integer, parameter :: UNIT_SUMMARY = 11 ! unit # for writing summary file

View file

@ -24,7 +24,7 @@ contains
! Start finalization timer
call timer_start(time_finalize)
if (.not. plotting) then
if (run_mode /= MODE_PLOTTING) then
! Calculate statistics for tallies and write to tallies.out
call tally_statistics()
if (master) call write_tallies()
@ -36,7 +36,7 @@ contains
! stop timers and show timing statistics
call timer_stop(time_finalize)
call timer_stop(time_total)
if (master .and. (.not. plotting)) call print_runtime()
if (master .and. (run_mode /= MODE_PLOTTING)) call print_runtime()
#ifdef HDF5
! Write time statistics to HDF5 output

View file

@ -258,7 +258,7 @@ contains
call write_message()
end if
if (surf % bc == BC_VACUUM .and. (.not. plotting)) then
if (surf % bc == BC_VACUUM .and. (run_mode /= MODE_PLOTTING)) then
! =======================================================================
! PARTICLE LEAKS OUT OF PROBLEM
@ -289,7 +289,7 @@ contains
end if
return
elseif (surf % bc == BC_REFLECT .and. (.not. plotting)) then
elseif (surf % bc == BC_REFLECT .and. (run_mode /= MODE_PLOTTING)) then
! =======================================================================
! PARTICLE REFLECTS FROM SURFACE
@ -447,7 +447,7 @@ contains
call find_cell(found)
! Couldn't find next cell anywhere!
if ((.not. found) .and. (.not. plotting)) then
if ((.not. found) .and. (run_mode /= MODE_PLOTTING)) then
message = "After particle " // trim(to_str(p % id)) // " crossed surface " &
// trim(to_str(surfaces(abs(p%surface)) % id)) // " it could not be &
&located in any cell and it did not leak."

View file

@ -205,11 +205,6 @@ module global
real(8) :: weight_cutoff = 0.25
real(8) :: weight_survive = 1.0
! ============================================================================
! PLOTTING VARIABLES
logical :: plotting = .false.
! ============================================================================
! HDF5 VARIABLES
@ -221,6 +216,9 @@ module global
! ============================================================================
! MISCELLANEOUS VARIABLES
! Mode to run in (fixed source, criticality, plotting, etc)
integer :: run_mode = MODE_CRITICALITY
character(MAX_FILE_LEN) :: path_input ! Path to input file
character(MAX_FILE_LEN) :: path_cross_sections ! Path to cross_sections.xml
@ -230,9 +228,6 @@ module global
! Random number seed
integer(8) :: seed = 1_8
! Problem type
integer :: problem_type = PROB_CRITICALITY
! The verbosity controls how much information will be printed to the
! screen and in logs
integer :: verbosity = 7

View file

@ -71,7 +71,7 @@ contains
subroutine hdf5_write_summary()
! Write criticality information
if (problem_type == PROB_CRITICALITY) then
if (run_mode == MODE_CRITICALITY) then
! Need to write integer(8)'s using double instead since there is no H5LT
! call for making a dataset of type long
call hdf5_make_double(hdf5_output_file, "n_particles", real(n_particles,8))

View file

@ -82,7 +82,7 @@ contains
! Read plots.xml if it exists -- this has to be done separate from the other
! XML files because we need the PRNG to be initialized first
if (plotting) call read_plots_xml()
if (run_mode == MODE_PLOTTING) call read_plots_xml()
! Set up universe structures
call prepare_universes()
@ -94,7 +94,7 @@ contains
! neighboring cells for efficient tracking
call neighbor_lists()
if (.not. plotting) then
if (run_mode /= MODE_PLOTTING) then
! Read cross section summary file to determine what files contain
! cross-sections
call read_cross_sections_xml()
@ -124,7 +124,7 @@ contains
! stop timer for initialization
if (master) then
if (plotting) then
if (run_mode == MODE_PLOTTING) then
call print_geometry()
call print_plot()
else
@ -243,7 +243,7 @@ contains
if (starts_with(argv(i), "-")) then
select case (argv(i))
case ('-p', '-plot', '--plot')
plotting = .true.
run_mode = MODE_PLOTTING
case ('-?', '-help', '--help')
call print_usage()
stop

View file

@ -95,7 +95,7 @@ contains
! Criticality information
if (criticality % batches > 0) then
problem_type = PROB_CRITICALITY
if (run_mode /= MODE_PLOTTING) run_mode = MODE_CRITICALITY
! Check number of particles
if (len_trim(criticality % particles) == 0) then

View file

@ -23,12 +23,13 @@ program main
! set up problem
call initialize_run()
! start problem
if (plotting) then
! start problem based on mode
select case (run_mode)
case (MODE_CRITICALITY)
call run_criticality()
case (MODE_PLOTTING)
call run_plot()
else
call run_problem()
end if
end select
! finalize run
call finalize_run()
@ -36,11 +37,11 @@ program main
contains
!===============================================================================
! RUN_PROBLEM encompasses all the main logic where iterations are performed over
! the cycles and histories.
! RUN_CRITICALITY encompasses all the main logic where iterations are performed
! over the cycles and histories.
!===============================================================================
subroutine run_problem()
subroutine run_criticality()
integer(8) :: i ! index over histories in single cycle
@ -147,6 +148,6 @@ contains
if (master) call header("SIMULATION FINISHED", level=1)
end subroutine run_problem
end subroutine run_criticality
end program main

View file

@ -873,14 +873,15 @@ contains
! Display problem summary
call header("PROBLEM SUMMARY", unit=UNIT_SUMMARY)
if (problem_type == PROB_CRITICALITY) then
select case(run_mode)
case (MODE_CRITICALITY)
write(UNIT_SUMMARY,100) 'Problem type:', 'Criticality'
write(UNIT_SUMMARY,101) 'Number of Batches:', n_batches
write(UNIT_SUMMARY,101) 'Number of Inactive Batches:', n_inactive
write(UNIT_SUMMARY,101) 'Generations per Batch:', gen_per_batch
elseif (problem_type == PROB_SOURCE) then
case (MODE_FIXEDSOURCE)
write(UNIT_SUMMARY,100) 'Problem type:', 'External Source'
end if
end select
write(UNIT_SUMMARY,101) 'Number of Particles:', n_particles
! Display geometry summary