mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Split up initialize_source to itself and allocate_banks.
This commit is contained in:
parent
d72acda23e
commit
d8930cb55f
2 changed files with 30 additions and 16 deletions
|
|
@ -17,7 +17,7 @@ module initialize
|
|||
print_plot, create_summary_file, print_usage, &
|
||||
create_xs_summary_file, print_version
|
||||
use random_lcg, only: initialize_prng
|
||||
use source, only: initialize_source
|
||||
use source, only: allocate_banks, initialize_source
|
||||
use string, only: to_str, str_to_int, starts_with, ends_with, &
|
||||
lower_case
|
||||
use tally, only: create_tally_map
|
||||
|
|
@ -119,7 +119,8 @@ contains
|
|||
! Create tally map
|
||||
call create_tally_map()
|
||||
|
||||
! create source particles
|
||||
! allocate banks and create source particles
|
||||
call allocate_banks()
|
||||
call initialize_source()
|
||||
end if
|
||||
|
||||
|
|
|
|||
|
|
@ -20,29 +20,17 @@ module source
|
|||
contains
|
||||
|
||||
!===============================================================================
|
||||
! INITIALIZE_SOURCE initializes particles in the source bank
|
||||
! ALLOCATE_BANKS allocates memory for the fission and source banks
|
||||
!===============================================================================
|
||||
|
||||
subroutine initialize_source()
|
||||
subroutine allocate_banks()
|
||||
|
||||
integer(8) :: i ! loop index over bank sites
|
||||
integer :: j ! dummy loop index
|
||||
integer(8) :: bytes ! size of fission/source bank
|
||||
integer(8) :: id ! particle id
|
||||
integer :: alloc_err ! allocation error code
|
||||
real(8) :: r(3) ! sampled coordinates
|
||||
real(8) :: phi ! azimuthal angle
|
||||
real(8) :: mu ! cosine of polar angle
|
||||
real(8) :: E ! outgoing energy
|
||||
real(8) :: p_min(3) ! minimum coordinates of source
|
||||
real(8) :: p_max(3) ! maximum coordinates of source
|
||||
#ifndef NO_F2008
|
||||
type(Bank) :: bank_obj
|
||||
#endif
|
||||
|
||||
message = "Initializing source particles..."
|
||||
call write_message(6)
|
||||
|
||||
! Determine maximum amount of particles to simulate on each processor
|
||||
maxwork = ceiling(real(n_particles)/n_procs,8)
|
||||
|
||||
|
|
@ -55,6 +43,8 @@ contains
|
|||
|
||||
! Allocate source bank
|
||||
allocate(source_bank(maxwork), STAT=alloc_err)
|
||||
|
||||
! Check for allocation errors
|
||||
if (alloc_err /= 0) then
|
||||
#ifndef NO_F2008
|
||||
bytes = maxwork * storage_size(bank_obj) / 8
|
||||
|
|
@ -68,6 +58,8 @@ contains
|
|||
|
||||
! Allocate fission bank
|
||||
allocate(fission_bank(3*maxwork), STAT=alloc_err)
|
||||
|
||||
! Check for allocation errors
|
||||
if (alloc_err /= 0) then
|
||||
#ifndef NO_F2008
|
||||
bytes = 3 * maxwork * storage_size(bank_obj) / 8
|
||||
|
|
@ -79,6 +71,27 @@ contains
|
|||
call fatal_error()
|
||||
end if
|
||||
|
||||
end subroutine allocate_banks
|
||||
|
||||
!===============================================================================
|
||||
! INITIALIZE_SOURCE initializes particles in the source bank
|
||||
!===============================================================================
|
||||
|
||||
subroutine initialize_source()
|
||||
|
||||
integer(8) :: i ! loop index over bank sites
|
||||
integer :: j ! dummy loop index
|
||||
integer(8) :: id ! particle id
|
||||
real(8) :: r(3) ! sampled coordinates
|
||||
real(8) :: phi ! azimuthal angle
|
||||
real(8) :: mu ! cosine of polar angle
|
||||
real(8) :: E ! outgoing energy
|
||||
real(8) :: p_min(3) ! minimum coordinates of source
|
||||
real(8) :: p_max(3) ! maximum coordinates of source
|
||||
|
||||
message = "Initializing source particles..."
|
||||
call write_message(6)
|
||||
|
||||
if (external_source % type == SRC_FILE) then
|
||||
! Read the source from a binary file instead of sampling from some
|
||||
! assumed source distribution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue