Merge branch 'master' into cmfd_parallel

This commit is contained in:
Bryan Herman 2012-04-30 07:39:18 -07:00
commit 36f2cc720c
7 changed files with 94 additions and 68 deletions

View file

@ -139,7 +139,7 @@ module global
! ============================================================================
! CRITICALITY SIMULATION VARIABLES
integer(8) :: n_particles ! # of particles per generation
integer(8) :: n_particles = 0 ! # of particles per generation
integer :: n_batches ! # of batches
integer :: n_inactive ! # of inactive batches
integer :: n_active ! # of active batches

View file

@ -3,7 +3,7 @@ module initialize
use ace, only: read_xs
use bank_header, only: Bank
use constants
use datatypes, only: dict_create, dict_get_key, dict_has_key, &
use datatypes, only: dict_create, dict_get_key, dict_has_key, &
dict_keys
use datatypes_header, only: ListKeyValueII, DictionaryII
use energy_grid, only: unionized_grid
@ -18,7 +18,8 @@ module initialize
create_xs_summary_file, print_version
use random_lcg, only: initialize_prng
use source, only: initialize_source
use string, only: to_str, starts_with, ends_with, lower_case
use string, only: to_str, str_to_int, starts_with, ends_with, &
lower_case
use tally, only: create_tally_map
use tally_header, only: TallyObject
use timing, only: timer_start, timer_stop
@ -28,7 +29,7 @@ module initialize
#endif
#ifdef HDF5
use hdf5_interface, only: hdf5_create_output, hdf5_write_header, &
use hdf5_interface, only: hdf5_create_output, hdf5_write_header, &
hdf5_write_summary
#endif
@ -244,6 +245,17 @@ contains
select case (argv(i))
case ('-p', '-plot', '--plot')
run_mode = MODE_PLOTTING
case ('-n', '-n_particles', '--n_particles')
i = i + 1
! Read number of particles per cycle
n_particles = str_to_int(argv(i))
! Check that number specified was valid
if (n_particles == ERROR_INT) then
message = "Must specify integer after " // trim(argv(i-1)) // &
" command-line flag."
call fatal_error()
end if
case ('-?', '-help', '--help')
call print_usage()
stop

View file

@ -104,7 +104,10 @@ contains
message = "Need to specify number of particles per cycles."
call fatal_error()
end if
n_particles = str_to_int(criticality % particles)
! If the number of particles was specified as a command-line argument, we
! don't set it here
if (n_particles == 0) n_particles = str_to_int(criticality % particles)
! Copy cycle information
n_batches = criticality % batches

View file

@ -187,11 +187,11 @@ contains
index_local = 1
n_request = 0
SEND_SITES: do while (start < finish)
! Determine the index of the processor which has the first part of the
! source_bank for the local processor
neighbor = start / maxwork
! Determine the index of the processor which has the first part of the
! source_bank for the local processor
neighbor = start / maxwork
SEND_SITES: do while (start < finish)
! Determine the number of sites to send
n = min((neighbor + 1)*maxwork, finish) - start
@ -207,6 +207,11 @@ contains
start = start + n
index_local = index_local + n
neighbor = neighbor + 1
! Check for sites out of bounds -- this only happens in the rare
! circumstance that a processor close to the end has so many sites that
! it would exceed the bank on the last processor
if (neighbor > n_procs - 1) exit
end do SEND_SITES
! ==========================================================================
@ -256,7 +261,7 @@ contains
neighbor = neighbor + 1
end do RECV_SITES
! Send we initiated a series of asynchronous ISENDs and IRECVs, now we have
! Since we initiated a series of asynchronous ISENDs and IRECVs, now we have
! to ensure that the data has actually been communicated before moving on to
! the next generation
@ -373,7 +378,8 @@ contains
call MPI_REDUCE(MPI_IN_PLACE, k_batch, 1, MPI_REAL8, MPI_SUM, 0, &
MPI_COMM_WORLD, mpi_err)
else
call MPI_REDUCE(k_batch, k_batch, 1, MPI_REAL8, MPI_SUM, 0, &
! Receive buffer not significant at other processors
call MPI_REDUCE(k_batch, temp, 1, MPI_REAL8, MPI_SUM, 0, &
MPI_COMM_WORLD, mpi_err)
end if
#endif

View file

@ -170,7 +170,8 @@ contains
logical :: in_mesh ! was single site outside mesh?
logical :: outside ! was any site outside mesh?
#ifdef MPI
integer :: n ! total size of count variable
integer :: n ! total size of count variable
real(8) :: dummy ! temporary receive buffer for non-root reductions
#endif
! initialize variables
@ -229,7 +230,8 @@ contains
call MPI_REDUCE(MPI_IN_PLACE, cnt, n, MPI_REAL8, MPI_SUM, 0, &
MPI_COMM_WORLD, mpi_err)
else
call MPI_REDUCE(cnt, cnt, n, MPI_REAL8, MPI_SUM, 0, &
! Receive buffer not significant at other processors
call MPI_REDUCE(cnt, dummy, n, MPI_REAL8, MPI_SUM, 0, &
MPI_COMM_WORLD, mpi_err)
end if

View file

@ -95,7 +95,7 @@ contains
! scores array for tally
score_bins = t % n_score_bins
t % n_total_bins = filter_bins
allocate(t % scores(filter_bins, score_bins))
allocate(t % scores(score_bins, filter_bins))
! All the remaining logic is for non-surface-current tallies so we can
! safely skip it
@ -189,7 +189,7 @@ contains
! Allocate scores for tally
t % n_total_bins = filter_bins
allocate(t % scores(filter_bins, score_bins))
allocate(t % scores(score_bins, filter_bins))
end do
@ -450,7 +450,7 @@ contains
end select
! Add score to tally
call add_to_score(t % scores(score_index, j), score)
call add_to_score(t % scores(j, score_index), score)
end do
@ -511,7 +511,7 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
! Add score to tally
call add_to_score(t % scores(score_index, j), score)
call add_to_score(t % scores(j, score_index), score)
end do
! reset outgoing energy bin and score index
@ -598,7 +598,7 @@ contains
end select
! Add score to tally
call add_to_score(t % scores(score_index, j), score)
call add_to_score(t % scores(j, score_index), score)
end do
@ -838,7 +838,7 @@ contains
end select
! Add score to tally
call add_to_score(t % scores(score_index, i), score)
call add_to_score(t % scores(i, score_index), score)
end do SCORE_LOOP
end if
@ -1057,7 +1057,7 @@ contains
bins(SURF_FILTER_SURFACE) = OUT_TOP
bins(1:3) = ijk0 + 1
score_index = sum((bins - 1) * t % stride) + 1
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
end do
else
@ -1067,7 +1067,7 @@ contains
bins(SURF_FILTER_SURFACE) = IN_TOP
bins(1:3) = ijk0 + 1
score_index = sum((bins - 1) * t % stride) + 1
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
end do
end if
@ -1081,7 +1081,7 @@ contains
bins(SURF_FILTER_SURFACE) = OUT_FRONT
bins(1:3) = ijk0 + 1
score_index = sum((bins - 1) * t % stride) + 1
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
end do
else
@ -1091,7 +1091,7 @@ contains
bins(SURF_FILTER_SURFACE) = IN_FRONT
bins(1:3) = ijk0 + 1
score_index = sum((bins - 1) * t % stride) + 1
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
end do
end if
@ -1105,7 +1105,7 @@ contains
bins(SURF_FILTER_SURFACE) = OUT_RIGHT
bins(1:3) = ijk0 + 1
score_index = sum((bins - 1) * t % stride) + 1
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
end do
else
@ -1115,7 +1115,7 @@ contains
bins(SURF_FILTER_SURFACE) = IN_RIGHT
bins(1:3) = ijk0 + 1
score_index = sum((bins - 1) * t % stride) + 1
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
end do
end if
@ -1231,7 +1231,7 @@ contains
end if
! Add to surface current tally
call add_to_score(t % scores(score_index, 1), p % wgt)
call add_to_score(t % scores(1, score_index), p % wgt)
end if
! Calculate new coordinates
@ -1347,16 +1347,17 @@ contains
integer :: n_bins ! total number of bins
real(8), allocatable :: tally_temp(:,:) ! contiguous array of scores
real(8) :: global_temp(N_GLOBAL_TALLIES)
real(8) :: dummy ! temporary receive buffer for non-root reduces
type(TallyObject), pointer :: t => null()
do i = 1, n_tallies
t => tallies(i)
n = t % n_total_bins
m = t % n_score_bins
n_bins = n*m
n = t % n_total_bins
n_bins = m*n
allocate(tally_temp(n,m))
allocate(tally_temp(m,n))
tally_temp = t % scores(:,:) % value
@ -1370,7 +1371,7 @@ contains
t % scores(:,:) % value = tally_temp
else
! Receive buffer not significant at other processors
call MPI_REDUCE(tally_temp, tally_temp, n_bins, MPI_REAL8, &
call MPI_REDUCE(tally_temp, dummy, n_bins, MPI_REAL8, &
MPI_SUM, 0, MPI_COMM_WORLD, mpi_err)
! Reset value on other processors
@ -1390,7 +1391,8 @@ contains
! Transfer values back to global_tallies on master
global_tallies(:) % value = global_temp
else
call MPI_REDUCE(global_temp, global_temp, N_GLOBAL_TALLIES, &
! Receive buffer not significant at other processors
call MPI_REDUCE(global_temp, dummy, N_GLOBAL_TALLIES, &
MPI_REAL8, MPI_SUM, 0, MPI_COMM_WORLD, mpi_err)
! Reset value on other processors
@ -1404,7 +1406,8 @@ contains
call MPI_REDUCE(MPI_IN_PLACE, total_weight, 1, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
else
call MPI_REDUCE(total_weight, total_weight, 1, MPI_REAL8, MPI_SUM, &
! Receive buffer not significant at other processors
call MPI_REDUCE(total_weight, dummy, 1, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
end if
end if
@ -1428,16 +1431,17 @@ contains
integer :: n_bins ! total number of bins
real(8), allocatable :: tally_temp(:,:,:) ! contiguous array of scores
real(8) :: global_temp(2,N_GLOBAL_TALLIES)
real(8) :: dummy ! temporary receive buffer for non-root reduces
type(TallyObject), pointer :: t => null()
do i = 1, n_tallies
t => tallies(i)
n = t % n_total_bins
m = t % n_score_bins
n_bins = n*m*2
n = t % n_total_bins
n_bins = m*n*2
allocate(tally_temp(2,n,m))
allocate(tally_temp(2,m,n))
tally_temp(1,:,:) = t % scores(:,:) % sum
tally_temp(2,:,:) = t % scores(:,:) % sum_sq
@ -1453,7 +1457,7 @@ contains
t % scores(:,:) % sum_sq = tally_temp(2,:,:)
else
! Receive buffer not significant at other processors
call MPI_REDUCE(tally_temp, tally_temp, n_bins, MPI_REAL8, MPI_SUM, &
call MPI_REDUCE(tally_temp, dummy, n_bins, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
end if
@ -1477,7 +1481,7 @@ contains
global_tallies(:) % sum_sq = global_temp(2,:)
else
! Receive buffer not significant at other processors
call MPI_REDUCE(global_temp, global_temp, n_bins, MPI_REAL8, MPI_SUM, &
call MPI_REDUCE(global_temp, dummy, n_bins, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
end if
@ -1635,8 +1639,8 @@ contains
do k = 1, t % n_score_bins
write(UNIT=UNIT_TALLY, FMT='(1X,2A,1X,A,"+/- ",A)') &
repeat(" ", indent), score_name(abs(t % score_bins(k) % scalar)), &
to_str(t % scores(score_index,k) % sum), &
trim(to_str(t % scores(score_index,k) % sum_sq))
to_str(t % scores(k,score_index) % sum), &
trim(to_str(t % scores(k,score_index) % sum_sq))
end do
indent = indent - 2
@ -1712,15 +1716,15 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Outgoing Current to Left", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
bins(SURF_FILTER_SURFACE) = OUT_RIGHT
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Incoming Current from Left", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
! Right Surface
bins(1:3) = (/ i, j, k /) + 1
@ -1728,15 +1732,15 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Incoming Current from Right", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
bins(SURF_FILTER_SURFACE) = OUT_RIGHT
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Outgoing Current to Right", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
! Back Surface
bins(1:3) = (/ i, j-1, k /) + 1
@ -1744,15 +1748,15 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Outgoing Current to Back", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
bins(SURF_FILTER_SURFACE) = OUT_FRONT
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Incoming Current from Back", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
! Front Surface
bins(1:3) = (/ i, j, k /) + 1
@ -1760,15 +1764,15 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Incoming Current from Front", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
bins(SURF_FILTER_SURFACE) = OUT_FRONT
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Outgoing Current to Front", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
! Bottom Surface
bins(1:3) = (/ i, j, k-1 /) + 1
@ -1776,15 +1780,15 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Outgoing Current to Bottom", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
bins(SURF_FILTER_SURFACE) = OUT_TOP
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Incoming Current from Bottom", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
! Top Surface
bins(1:3) = (/ i, j, k /) + 1
@ -1792,15 +1796,15 @@ contains
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Incoming Current from Top", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
bins(SURF_FILTER_SURFACE) = OUT_TOP
score_index = sum((bins - 1) * t % stride) + 1
write(UNIT=UNIT_TALLY, FMT='(5X,A,T35,A,"+/- ",A)') &
"Outgoing Current to Top", &
to_str(t % scores(score_index,1) % sum), &
trim(to_str(t % scores(score_index,1) % sum_sq))
to_str(t % scores(1,score_index) % sum), &
trim(to_str(t % scores(1,score_index) % sum_sq))
end do
end do

View file

@ -99,11 +99,10 @@ module tally_header
type(TallyFilter), pointer :: score_bins(:) => null()
integer :: n_score_bins = 0
! Scores for each bin -- the most natural way to have scores would be to
! have a dimension for each different type of bin, but older Fortran
! standards are limited to 7 dimensions or less, so instead we map a
! combination of the filter bins into one integer and have that as the
! index into a one-dimensional array
! Scores for each bin -- the first dimenion of the array is for scores
! (e.g. flux, total reaction rate, fission reaction rate, etc.) and the
! second dimension of the array is for the combination of filters
! (e.g. specific cell, specific energy group, etc.)
type(TallyScore), allocatable :: scores(:,:)