Skip to content

Commit

Permalink
Merge pull request openmc-dev#320 from bhermanmit/ptable-fix
Browse files Browse the repository at this point in the history
Valgrind fixes for ptable-resample and res-scat additions
  • Loading branch information
walshjon committed Sep 12, 2014
2 parents 55fb5a5 + b5839d9 commit 1a2093f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
9 changes: 2 additions & 7 deletions src/ace.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module ace
use error, only: fatal_error, warning
use fission, only: nu_total
use global
use list_header, only: ListElemInt, ListInt
use list_header, only: ListInt
use material_header, only: Material
use output, only: write_message
use set_header, only: SetChar
Expand Down Expand Up @@ -1563,16 +1563,11 @@ subroutine same_nuclide_list()

integer :: i ! index in nuclides array
integer :: j ! index in nuclides array
type(ListElemInt), pointer :: nuc_list => null() ! pointer to nuclide list

do i = 1, n_nuclides_total
allocate(nuclides(i) % nuc_list)
nuc_list => nuclides(i) % nuc_list
do j = 1, n_nuclides_total
if (nuclides(i) % zaid == nuclides(j) % zaid) then
nuc_list % data = j
allocate(nuc_list % next)
nuc_list => nuc_list % next
call nuclides(i) % nuc_list % append(j)
end if
end do
end do
Expand Down
8 changes: 5 additions & 3 deletions src/ace_header.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ace_header

use constants, only: MAX_FILE_LEN
use endf_header, only: Tab1
use list_header, only: ListElemInt
use list_header, only: ListInt

implicit none

Expand Down Expand Up @@ -97,7 +97,7 @@ module ace_header
real(8) :: kT ! temperature in MeV (k*T)

! Linked list of indices in nuclides array of instances of this same nuclide
type(ListElemInt), pointer :: nuc_list => null()
type(ListInt) :: nuc_list

! Energy grid information
integer :: n_grid ! # of nuclide grid points
Expand All @@ -114,7 +114,7 @@ module ace_header

! Resonance scattering info
logical :: resonant = .false. ! resonant scatterer?
character(10) :: name_0K ! name of 0K nuclide, e.g. 92235.00c
character(10) :: name_0K = '' ! name of 0K nuclide, e.g. 92235.00c
character(16) :: scheme ! target velocity sampling scheme
integer :: n_grid_0K ! number of 0K energy grid points
real(8), allocatable :: energy_0K(:) ! energy grid for 0K xs
Expand Down Expand Up @@ -416,6 +416,8 @@ subroutine nuclide_clear(this)
deallocate(this % reactions)
end if

call this % nuc_list % clear()

end subroutine nuclide_clear

end module ace_header
35 changes: 17 additions & 18 deletions src/cross_section.F90
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,22 @@ subroutine calculate_urr_xs(i_nuclide, E)
integer, intent(in) :: i_nuclide ! index into nuclides array
real(8), intent(in) :: E ! energy

integer :: i_energy ! index for energy
integer :: i_low ! band index at lower bounding energy
integer :: i_up ! band index at upper bounding energy
real(8) :: f ! interpolation factor
real(8) :: r ! pseudo-random number
real(8) :: elastic ! elastic cross section
real(8) :: capture ! (n,gamma) cross section
real(8) :: fission ! fission cross section
real(8) :: inelastic ! inelastic cross section
logical :: same_nuc ! do we know the xs for this nuclide at this energy?
integer :: i ! loop index
integer :: i_energy ! index for energy
integer :: i_low ! band index at lower bounding energy
integer :: i_up ! band index at upper bounding energy
integer :: same_nuc_idx ! index of same nuclide
real(8) :: f ! interpolation factor
real(8) :: r ! pseudo-random number
real(8) :: elastic ! elastic cross section
real(8) :: capture ! (n,gamma) cross section
real(8) :: fission ! fission cross section
real(8) :: inelastic ! inelastic cross section
logical :: same_nuc ! do we know the xs for this nuclide at this energy?
type(UrrData), pointer, save :: urr => null()
type(Nuclide), pointer, save :: nuc => null()
type(Reaction), pointer, save :: rxn => null()
type(ListElemInt), pointer :: nuc_list => null()
!$omp threadprivate(urr, nuc, rxn, nuc_list)
!$omp threadprivate(urr, nuc, rxn)

micro_xs(i_nuclide) % use_ptable = .true.

Expand All @@ -381,18 +382,16 @@ subroutine calculate_urr_xs(i_nuclide, E)
! this energy but a different temperature, use the original random number to
! preserve correlation of temperature in probability tables
same_nuc = .false.
nuc_list => nuc % nuc_list
do
if (E /= ZERO .and. E == micro_xs(nuc_list % data) % last_E) then
do i = 1, nuc % nuc_list % size()
if (E /= ZERO .and. E == micro_xs(nuc % nuc_list % get_item(i)) % last_E) then
same_nuc = .true.
same_nuc_idx = i
exit
end if
nuc_list => nuc_list % next
if (.not. associated(nuc_list % next)) exit
end do

if (same_nuc) then
r = micro_xs(nuc_list % data) % last_prn
r = micro_xs(nuc % nuc_list % get_item(same_nuc_idx)) % last_prn
else
r = prn()
micro_xs(i_nuclide) % last_prn = r
Expand Down

0 comments on commit 1a2093f

Please sign in to comment.