mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Enabled using binary source of any size in serial runs.
This commit is contained in:
parent
dfed146d3b
commit
2d48cfa849
1 changed files with 30 additions and 9 deletions
|
|
@ -266,7 +266,9 @@ contains
|
|||
|
||||
subroutine read_source_binary()
|
||||
|
||||
integer(8) :: n_sites ! number of sites in binary file
|
||||
integer(8) :: n_sites ! number of sites in binary file
|
||||
integer :: i ! loop over repeating sites
|
||||
integer :: n_repeat ! number of times to repeat a site
|
||||
#ifdef MPI
|
||||
integer :: fh ! file handle
|
||||
integer(MPI_OFFSET_KIND) :: offset ! offset in memory (0=beginning of file)
|
||||
|
|
@ -313,15 +315,34 @@ contains
|
|||
! Read number of source sites in file
|
||||
read(UNIT=UNIT_SOURCE) n_sites
|
||||
|
||||
! Check that number of source sites matches
|
||||
if (n_sites /= n_particles) then
|
||||
message = "No support yet for source files of different size than &
|
||||
&specified number of particles per generation."
|
||||
call fatal_error()
|
||||
end if
|
||||
if (n_particles > n_sites) then
|
||||
! The size of the source file is smaller than the number of particles we
|
||||
! need. Thus, read all sites and then duplicate sites as necessary.
|
||||
|
||||
! Read source sites
|
||||
read(UNIT=UNIT_SOURCE) source_bank(1:work)
|
||||
read(UNIT=UNIT_SOURCE) source_bank(1:n_sites)
|
||||
|
||||
! Let's say we have 300 sites and we need to fill in 1000. This do loop
|
||||
! will fill in sites 301 - 900.
|
||||
|
||||
n_repeat = int(n_particles / n_sites)
|
||||
do i = 1, n_repeat - 1
|
||||
source_bank(i*n_sites + 1:(i+1)*n_sites) = &
|
||||
source_bank((i-1)*n_sites + 1:i*n_sites)
|
||||
end do
|
||||
|
||||
! This final statement would fill sites 901 - 1000 in the above example.
|
||||
|
||||
source_bank(n_repeat*n_sites + 1:n_particles) = &
|
||||
source_bank(1:n_particles - n_repeat * n_sites)
|
||||
|
||||
else
|
||||
! The size of the source file is bigger than or equal to the number of
|
||||
! particles we need for one generation. Thus, we can just read as many
|
||||
! sites as we need.
|
||||
|
||||
read(UNIT=UNIT_SOURCE) source_bank(1:n_particles)
|
||||
|
||||
end if
|
||||
|
||||
! Close binary source file
|
||||
close(UNIT=UNIT_SOURCE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue