Added global variables current_cycle and n_active.

This commit is contained in:
Paul Romano 2012-01-31 16:11:16 -05:00
parent 8a8404362e
commit b736b1bc59
5 changed files with 28 additions and 29 deletions

View file

@ -104,6 +104,8 @@ module global
integer(8) :: n_particles = 10000 ! # of particles per cycle
integer :: n_cycles = 500 ! # of cycles
integer :: n_inactive = 50 ! # of inactive cycles
integer :: n_active ! # of active cycles
integer :: current_cycle ! current cycle
! External source
type(ExtSource), target :: external_source

View file

@ -77,7 +77,7 @@ contains
! Use H5LT interface to write n_cycles, n_inactive, and n_active
call hdf5_make_integer(hdf5_output_file, "n_cycles", n_cycles)
call hdf5_make_integer(hdf5_output_file, "n_inactive", n_inactive)
call hdf5_make_integer(hdf5_output_file, "n_active", n_cycles - n_inactive)
call hdf5_make_integer(hdf5_output_file, "n_active", n_active)
! Add description of each variable
call h5ltset_attribute_string_f(hdf5_output_file, "n_particles", &

View file

@ -94,6 +94,7 @@ contains
n_particles = criticality % particles
n_cycles = criticality % cycles
n_inactive = criticality % inactive
n_active = n_cycles - n_inactive
end if
! Verbosity

View file

@ -22,9 +22,7 @@ contains
! scale to large numbers of processors where other codes cannot.
!===============================================================================
subroutine synchronize_bank(i_cycle)
integer, intent(in) :: i_cycle
subroutine synchronize_bank()
integer :: i, j, k ! loop indices
integer(8) :: start ! starting index in local fission bank
@ -73,7 +71,7 @@ contains
end if
! Make sure all processors start at the same point for random sampling
call set_particle_seed(int(i_cycle,8))
call set_particle_seed(int(current_cycle,8))
! Skip ahead however many random numbers are needed
call prn_skip(start)
@ -422,9 +420,7 @@ contains
! mean and standard deviation of the mean for active cycles and displays them
!===============================================================================
subroutine calculate_keff(i_cycle)
integer, intent(in) :: i_cycle ! index of current cycle
subroutine calculate_keff()
integer(8) :: total_bank ! total number of source sites
integer :: n ! active cycle number
@ -436,7 +432,7 @@ contains
call write_message(8)
! initialize sum and square of sum at beginning of run
if (i_cycle == 1) then
if (current_cycle == 1) then
k_sum = ZERO
k_sum_sq = ZERO
end if
@ -457,9 +453,9 @@ contains
k_cycle = real(total_bank)/real(n_particles)*keff
if (i_cycle > n_inactive) then
if (current_cycle > n_inactive) then
! Active cycle number
n = i_cycle - n_inactive
n = current_cycle - n_inactive
! Accumulate cycle estimate of k
k_sum = k_sum + k_cycle
@ -470,26 +466,27 @@ contains
keff_std = sqrt((k_sum_sq/n - keff*keff)/n)
! Display output for this cycle
if (i_cycle > n_inactive+1) then
if (current_cycle > n_inactive + 1) then
if (entropy_on) then
write(UNIT=OUTPUT_UNIT, FMT=103) i_cycle, k_cycle, entropy, &
keff, keff_std
write(UNIT=OUTPUT_UNIT, FMT=103) current_cycle, k_cycle, &
entropy, keff, keff_std
else
write(UNIT=OUTPUT_UNIT, FMT=101) i_cycle, k_cycle, keff, keff_std
write(UNIT=OUTPUT_UNIT, FMT=101) current_cycle, k_cycle, &
keff, keff_std
end if
else
if (entropy_on) then
write(UNIT=OUTPUT_UNIT, FMT=102) i_cycle, k_cycle, entropy
write(UNIT=OUTPUT_UNIT, FMT=102) current_cycle, k_cycle, entropy
else
write(UNIT=OUTPUT_UNIT, FMT=100) i_cycle, k_cycle
write(UNIT=OUTPUT_UNIT, FMT=100) current_cycle, k_cycle
end if
end if
else
! Display output for inactive cycle
if (entropy_on) then
write(UNIT=OUTPUT_UNIT, FMT=102) i_cycle, k_cycle, entropy
write(UNIT=OUTPUT_UNIT, FMT=102) current_cycle, k_cycle, entropy
else
write(UNIT=OUTPUT_UNIT, FMT=100) i_cycle, k_cycle
write(UNIT=OUTPUT_UNIT, FMT=100) current_cycle, k_cycle
end if
keff = k_cycle
end if

View file

@ -43,8 +43,7 @@ contains
subroutine run_problem()
integer :: i_cycle ! cycle index
integer(8) :: i_particle ! history index
integer(8) :: particle_seed ! unique index for particle
type(Particle), pointer :: p => null()
if (master) call header("BEGIN SIMULATION", level=1)
@ -67,12 +66,12 @@ contains
! ==========================================================================
! LOOP OVER CYCLES
CYCLE_LOOP: do i_cycle = 1, n_cycles
CYCLE_LOOP: do current_cycle = 1, n_cycles
! Start timer for computation
call timer_start(time_compute)
message = "Simulating cycle " // trim(to_str(i_cycle)) // "..."
message = "Simulating cycle " // trim(to_str(current_cycle)) // "..."
call write_message(8)
! Set all tallies to zero
@ -90,12 +89,12 @@ contains
end if
! set random number seed
i_particle = (i_cycle-1)*n_particles + p % id
call set_particle_seed(i_particle)
particle_seed = (current_cycle - 1)*n_particles + p % id
call set_particle_seed(particle_seed)
! set particle trace
trace = .false.
if (i_cycle == trace_cycle .and. &
if (current_cycle == trace_cycle .and. &
p % id == trace_particle) trace = .true.
! transport particle
@ -123,15 +122,15 @@ contains
if (entropy_on) call shannon_entropy()
! Distribute fission bank across processors evenly
call synchronize_bank(i_cycle)
call synchronize_bank()
! Collect results and statistics
call calculate_keff(i_cycle)
call calculate_keff()
! print cycle information
! Turn tallies on once inactive cycles are complete
if (i_cycle == n_inactive) then
if (current_cycle == n_inactive) then
tallies_on = .true.
call timer_stop(time_inactive)
call timer_start(time_active)