From d8930cb55f2c66fc7e40b12eb76588556fd4a988 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 1 May 2012 18:23:59 -0500 Subject: [PATCH] Split up initialize_source to itself and allocate_banks. --- src/initialize.F90 | 5 +++-- src/source.F90 | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/initialize.F90 b/src/initialize.F90 index ea4288c852..39830da387 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -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 diff --git a/src/source.F90 b/src/source.F90 index 68796ad182..24ab1a32b0 100644 --- a/src/source.F90 +++ b/src/source.F90 @@ -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