From 44a607c84f9675947317869ec1bd34b9155f0a92 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 15 Aug 2013 08:33:28 -0500 Subject: [PATCH 1/5] Simplify str_to_real. --- src/ace.F90 | 2 +- src/string.F90 | 39 ++++----------------------------------- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/ace.F90 b/src/ace.F90 index 4492d6b8b9..2617bcbed4 100644 --- a/src/ace.F90 +++ b/src/ace.F90 @@ -10,7 +10,7 @@ module ace use material_header, only: Material use output, only: write_message use set_header, only: SetChar - use string, only: str_to_int, str_to_real, lower_case, to_str + use string, only: to_str implicit none diff --git a/src/string.F90 b/src/string.F90 index 3f0c87219a..e322894b55 100644 --- a/src/string.F90 +++ b/src/string.F90 @@ -322,49 +322,18 @@ contains end function str_to_int !=============================================================================== -! STR_TO_REAL converts an arbitrary string to a real(8). Generally this function -! is intended for strings for which the exact format is not known. If the format -! of the number is known a priori, the appropriate format descriptor should be -! used in lieu of this routine because of the extra overhead. -! -! Arguments: -! string = character(*) containing number to convert +! STR_TO_REAL converts an arbitrary string to a real(8) !=============================================================================== function str_to_real(string) result(num) character(*), intent(in) :: string - real(8) :: num + real(8) :: num - integer :: index_decimal ! index of decimal point - integer :: index_exponent ! index of exponent character - integer :: w ! total field width - integer :: d ! number of digits to right of decimal point - integer :: ioError - character(8) :: fmt ! format for reading string - - ! Determine total field width - w = len_trim(string) - - ! Determine number of digits to right of decimal point - index_decimal = index(string, '.') - index_exponent = max(index(string, 'd'), index(string, 'D'), & - index(string, 'e'), index(string, 'E')) - if (index_decimal > 0) then - if (index_exponent > 0) then - d = index_exponent - index_decimal - 1 - else - d = w - index_decimal - end if - else - d = 0 - end if - - ! Create format specifier for reading string - write(fmt, '("(E",I2,".",I2,")")') w, d + integer :: ioError ! Read string - read(UNIT=string, FMT=fmt, IOSTAT=ioError) num + read(UNIT=string, FMT=*, IOSTAT=ioError) num if (ioError > 0) num = ERROR_REAL end function str_to_real From c1fae67b5010efa5bc5b84e1abb9a78063455b48 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 16 Aug 2013 10:15:55 -0400 Subject: [PATCH 2/5] slepc module now commented out with compiler directive now that OBJECTS is gone --- src/cmfd_slepc_solver.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmfd_slepc_solver.F90 b/src/cmfd_slepc_solver.F90 index fb32c2e1ad..4b5ba7d58e 100644 --- a/src/cmfd_slepc_solver.F90 +++ b/src/cmfd_slepc_solver.F90 @@ -1,6 +1,6 @@ module cmfd_slepc_solver -#ifdef PETSC +#ifdef SLEPC use cmfd_loss_operator, only: loss_operator, init_M_operator, & build_loss_matrix, destroy_M_operator use cmfd_prod_operator, only: prod_operator, init_F_operator, & From 01cd47d0e0fa3bd42a4d0ad7410a5543f8c1106a Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sun, 18 Aug 2013 12:57:44 -0400 Subject: [PATCH 3/5] Added second nuclide to survival biasing test and updated results. --- tests/test_survival_biasing/materials.xml | 5 +++-- tests/test_survival_biasing/results_true.dat | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_survival_biasing/materials.xml b/tests/test_survival_biasing/materials.xml index 1f85510e0d..1382ad5952 100644 --- a/tests/test_survival_biasing/materials.xml +++ b/tests/test_survival_biasing/materials.xml @@ -2,8 +2,9 @@ - - + + + diff --git a/tests/test_survival_biasing/results_true.dat b/tests/test_survival_biasing/results_true.dat index 27f6ffb6d9..f733b4050d 100644 --- a/tests/test_survival_biasing/results_true.dat +++ b/tests/test_survival_biasing/results_true.dat @@ -1,2 +1,2 @@ k-combined: -0.30487324 0.00983400 +0.96880768 0.06981246 From 44170ed727a12728cd8accf161f41a6a8de4056d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sun, 18 Aug 2013 15:52:51 -0400 Subject: [PATCH 4/5] Describe how to switch to master branch in user's guide. --- docs/source/quickinstall.rst | 1 + docs/source/usersguide/install.rst | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/source/quickinstall.rst b/docs/source/quickinstall.rst index e6c9e4488e..2cee56987a 100644 --- a/docs/source/quickinstall.rst +++ b/docs/source/quickinstall.rst @@ -43,6 +43,7 @@ following commands in a terminal: git clone git://github.com/mit-crpg/openmc.git cd openmc/src + git checkout master make sudo make install diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index ef01aeff7f..d5ea3d9c2d 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -102,6 +102,12 @@ repository:: git clone git://github.com/mit-crpg/openmc.git +By default, the cloned repository will be set to the development branch. To +switch to the source of the latest stable release, run the following commands:: + + cd openmc/src + git checkout master + .. _GitHub: https://github.com/mit-crpg/openmc .. _git: http://git-scm.com .. _ssh: http://en.wikipedia.org/wiki/Secure_Shell From f16ca7f684218b281156a63cee745093d66a540d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 23 Aug 2013 11:26:08 -0400 Subject: [PATCH 5/5] Fix various memory leaks. --- src/eigenvalue.F90 | 3 +++ src/global.F90 | 16 ++++++++++++++++ src/initialize.F90 | 13 +++++++++---- src/particle_header.F90 | 23 ++++++++++++++++++++--- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/eigenvalue.F90 b/src/eigenvalue.F90 index 99e758bf38..ede4374f1c 100644 --- a/src/eigenvalue.F90 +++ b/src/eigenvalue.F90 @@ -98,6 +98,9 @@ contains ! END OF RUN WRAPUP if (master) call header("SIMULATION FINISHED", level=1) + + ! Clear particle + call p % clear() end subroutine run_eigenvalue diff --git a/src/global.F90 b/src/global.F90 index a7a7bfb972..362a308b2a 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -409,6 +409,19 @@ contains if (allocated(xs_listings)) deallocate(xs_listings) if (allocated(micro_xs)) deallocate(micro_xs) + ! Deallocate external source + if (allocated(external_source % params_space)) & + deallocate(external_source % params_space) + if (allocated(external_source % params_angle)) & + deallocate(external_source % params_angle) + if (allocated(external_source % params_energy)) & + deallocate(external_source % params_energy) + + ! Deallocate k and entropy + if (allocated(k_generation)) deallocate(k_generation) + if (allocated(entropy)) deallocate(entropy) + if (allocated(entropy_p)) deallocate(entropy_p) + ! Deallocate tally-related arrays if (allocated(meshes)) deallocate(meshes) if (allocated(tallies)) then @@ -450,6 +463,9 @@ contains call nuclide_dict % clear() call sab_dict % clear() call xs_listing_dict % clear() + + ! Clear statepoint batch set + call statepoint_batch % clear() end subroutine free_memory diff --git a/src/initialize.F90 b/src/initialize.F90 index da9194915c..1a9cc021fb 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -417,6 +417,8 @@ contains integer, allocatable :: index_cell_in_univ(:) ! the index in the univ%cells ! array for each universe type(ElemKeyValueII), pointer :: pair_list => null() + type(ElemKeyValueII), pointer :: current => null() + type(ElemKeyValueII), pointer :: next => null() type(Universe), pointer :: univ => null() type(Cell), pointer :: c => null() @@ -428,11 +430,12 @@ contains ! cells_in_univ_dict, it's the id of the universe and the number of cells. pair_list => universe_dict % keys() - do while (associated(pair_list)) + current => pair_list + do while (associated(current)) ! find index of universe in universes array - i_univ = pair_list % value + i_univ = current % value univ => universes(i_univ) - univ % id = pair_list % key + univ % id = current % key ! check for lowest level universe if (univ % id == 0) BASE_UNIVERSE = i_univ @@ -445,7 +448,9 @@ contains univ % n_cells = n_cells_in_univ ! move to next universe - pair_list => pair_list % next + next => current % next + deallocate(current) + current => next end do ! Also allocate a list for keeping track of where cells have been assigned diff --git a/src/particle_header.F90 b/src/particle_header.F90 index 75d8ac1de4..3f396b15eb 100644 --- a/src/particle_header.F90 +++ b/src/particle_header.F90 @@ -77,6 +77,7 @@ module particle_header contains procedure :: initialize => initialize_particle + procedure :: clear => clear_particle end type Particle contains @@ -110,6 +111,9 @@ contains class(Particle) :: this + ! Clear coordinate lists + call this % clear() + ! Set particle to neutron that's alive this % type = NEUTRON this % alive = .true. @@ -126,9 +130,6 @@ contains this % wgt_bank = ZERO this % n_collision = 0 - ! remove any original coordinates - call deallocate_coord(this % coord0) - ! Set up base level coordinates allocate(this % coord0) this % coord0 % universe = BASE_UNIVERSE @@ -136,4 +137,20 @@ contains end subroutine initialize_particle +!=============================================================================== +! CLEAR_PARTICLE +!=============================================================================== + + subroutine clear_particle(this) + + class(Particle) :: this + + ! remove any coordinate levels + call deallocate_coord(this % coord0) + + ! Make sure coord pointer is nullified + nullify(this % coord) + + end subroutine clear_particle + end module particle_header